Pages

Saturday, October 20, 2012

JSF 2.x Tip of the Day: Programmatically Creating EL MethodExpression

A common need is to create a MethodExpression for use in binding a JSF component action, or actionListener attributes to a value in the JSF/CDI managed beans.
Here is an example of how to use the method. In the example below I use both a ValueExpression and a MethodExpression for clarity. The MethodExpression is bound to a method called sort() in the IndexBean. Since this is bound to the action on the UICommandLink, it is expected that a String is returned which is used for determining navigation. Also note that an empty new Class[]{} array is passed as the expected parameter type.

No comments:

Post a Comment