To evaluate an EL expression from ADF managed classes, such as managed beans.
public Object getExpressionValue(String jsfExpression)
{
// when specifying EL expression in managed bean as "literal" value
// so t can be evaluated later, the # is replaced with $, quite strange
if (jsfExpression == null)
{
return jsfExpression;
}
if (jsfExpression.startsWith("${"))
{
jsfExpression = "#{" + jsfExpression.substring(2);
}
if (!jsfExpression.startsWith("#{"))
{
if (jsfExpression.equalsIgnoreCase("true"))
{
return Boolean.TRUE;
}
else if (jsfExpression.equalsIgnoreCase("false"))
{
return Boolean.FALSE;
}
// there can be literal text preceding the expression...
else if (jsfExpression.indexOf("#{")<0)
{
return jsfExpression;
}
}
ValueExpression ve = getApplication().getExpressionFactory().createValueExpression(getFacesContext().getELContext(),jsfExpression,Object.class);
return ve.getValue(getFacesContext().getELContext());
}
NOTE : This is widely available in ADF community, but I just wanted to make this available for directly for those who are looking for only this.
public Object getExpressionValue(String jsfExpression)
{
// when specifying EL expression in managed bean as "literal" value
// so t can be evaluated later, the # is replaced with $, quite strange
if (jsfExpression == null)
{
return jsfExpression;
}
if (jsfExpression.startsWith("${"))
{
jsfExpression = "#{" + jsfExpression.substring(2);
}
if (!jsfExpression.startsWith("#{"))
{
if (jsfExpression.equalsIgnoreCase("true"))
{
return Boolean.TRUE;
}
else if (jsfExpression.equalsIgnoreCase("false"))
{
return Boolean.FALSE;
}
// there can be literal text preceding the expression...
else if (jsfExpression.indexOf("#{")<0)
{
return jsfExpression;
}
}
ValueExpression ve = getApplication().getExpressionFactory().createValueExpression(getFacesContext().getELContext(),jsfExpression,Object.class);
return ve.getValue(getFacesContext().getELContext());
}
NOTE : This is widely available in ADF community, but I just wanted to make this available for directly for those who are looking for only this.
Comments
Post a Comment