You are here

Execute expression language from managed bean

Sometimes you will need to get a specific value that is only accessible by expression language.
The following snippet will provide you with a generic method that you can use all the time. It takes a single parameter being the expression and it returns an Object. You will have to do the casting as shown in the examples.
In ADF this can also be used to access the object from the binding.

  1. public static Object get(String expr) {
  2.   FacesContext ctx = FacesContext.getCurrentInstance()
  3.   return ctx.getApplication().evaluateExpressionGet(ctx, expr,Object.class);
  4. }
  1. String value = (String) get("#{myBean.value}");
Get the current row of a table: Code for the table in the JSPX:
  1. <af:table value="#{myBean.persons}" var="row">
  2.   ...
  3. </af:table>
  1. Person person = (Person) get("#{row}");

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer