EL functions with parameters in JSF

We managed to get rid of one of the biggest annoyance in JSF.

Project

The problem

In the tr:table and similar iterating components it isn't possible to print raw data with some non-trivial formatter or translator. Possible workarounds are:

Solution

Use an alternative JBoss EL resolver. It implements a feature to call methods with parameters. Our current workflow:

  1. Implement a formatter as a String returning method on singleton bean in spring context.
  2. Inject this bean to page's backing bean.
  3. In the tr:table body call formatter's method with current iteration value as a parameter.

Installation

Download JBoss, copy jboss-el.jar to your project's classpath and add context-param to your web.xml:


    com.sun.faces.expressionFactory
    org.jboss.el.ExpressionFactoryImpl

]]>

NOTE: Param name is JSF implementation specific, so for example it's org.apache.myfaces.EXPRESSION_FACTORY for MyFaces!

Sources:

Last update
201004010000