Skip to content

Instantly share code, notes, and snippets.

@biemond
Created September 28, 2011 18:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save biemond/1248773 to your computer and use it in GitHub Desktop.
Save biemond/1248773 to your computer and use it in GitHub Desktop.
FacesContext and ADF
// FacesContext
FacesContext facesCtx = FacesContext.getCurrentInstance();
// find UIComponent
UIComponent input = facesCtx.getViewRoot().findComponent("f1");
// change the locale
facesCtx.getViewRoot().setLocale( Locale.ENGLISH);
// el expression
Application app = facesCtx.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = facesCtx.getELContext();
ValueExpression valueExp = elFactory.createValueExpression(elContext,
"#{xxxx}",
Object.class);
Object result = valueExp.getValue(elContext);
// add a message
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_WARN,
"header",
"detail");
facesCtx.addMessage(input.getClientId(facesCtx), msg);
// ExternalContext
ExternalContext ectx = facesCtx.getExternalContext();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment