Friday, December 17, 2010

Resolving EL programmatically to retrieve value

EL is used in JSF to set values from java classes with User Interface. Sometimes, EL is needed to resolve programmatically to retrieve value. Sample method can be used for this purpose:

public static Object resolveExpression(String expression) {
FacesContext facesContext = getFacesContext();
Application app = facesContext.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = facesContext.getELContext();
ValueExpression valueExp =
elFactory.createValueExpression(elContext, expression,
return valueExp.getValue(elContext);

No comments:

Post a Comment