EL method expressions

With EL expressions, we can call arbitrary static and public methods that live on the server side in managed beans. Such expressions are usually present in tag's attributes (that is, inside an action or actionListener attribute) and must use the deferred evaluation syntax since a method can be called during different phases of the life cycle. Commonly, methods are called to respond with actions to different kinds of events and for autopages navigation.

Let's see some examples of calling bean methods using EL (all methods were defined in the PlayersBean managed bean):

  • Calling the vamosRafa_1 void bean method with no arguments, as shown in the following code:
    public void vamosRafa_1(){ System.out.println("Vamos Rafa!"); } #{playersBean.vamosRafa_1()} ...

Get Mastering JavaServer Faces 2.2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.