Java examples for javax.faces.context:FacesContext
get Value from resource bundle in Java Server Face
import java.util.ResourceBundle; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; public class Main{ public static void main(String[] argv) throws Exception{ String chave = "java2s.com"; System.out.println(getValor(chave)); }/*from w w w . jav a 2 s . c o m*/ private static ResourceBundle bundle; private static String getValor(String chave) { try { return getBundle().getString(chave); } catch (Exception e) { return chave; } } private static ResourceBundle getBundle() { if (bundle == null) { FacesContext context = FacesContext.getCurrentInstance(); bundle = context.getApplication().getResourceBundle(context, "msgs"); } return bundle; } }