get Text from FacesContext - Java javax.faces.context

Java examples for javax.faces.context:FacesContext

Introduction

The following code shows how to get Text.

Demo Code

import java.util.ResourceBundle;
import javax.faces.context.FacesContext;

public class Main{
    public static String getText(Enum e) {
        FacesContext context = FacesContext.getCurrentInstance();
        ResourceBundle bundle = context.getApplication().getResourceBundle(
                context, "texts");
        return bundle.getString(e.getClass().getSimpleName().toLowerCase()
                + e.name().toUpperCase());
    }//w ww  .j ava 2s  .  co  m
}

Related Tutorials