The Black Bean Source™
User Guide for EL-Functors 1.0.2

Introduction

This project is a functor object resolver library and tag library for the Java™ EE 5 unified expression language. It extends the expression language used in JSF1.2 and JSP2.1 pages to directly expose static and dynamic methods and constructors of plain Java objects or beans.

Quick Start

The EL-Functors library is an extension of the javax.el.ELResolver class. To use the EL-Functors, you just need to drop the EL-Functors-version.jar into the WEB-INF/lib folder of your project. Java Server Faces applications will automatically pick up the resolver from the META-INF/faces-config.xml entry in that jar. If you are using the EL in bare JSP (not accessed via JSF), then you also need to add the ServletContextListener reference to your web.xml descriptor like this:

    <listener>
        <listener-class>beanface.el.functor.InstallFunctorListener</listener-class>
    </listener>

Then the following types of EL expressions become available:

Reference Type EL-Resolver Expression TagLib Function Expression
Dynamic methods ${strValue.substring$2[3][strValue.length$ - 2]} ${el:dynamicMethod(strValue,'substring',2,false)[3][fn:length(strValue) - 2]}
Static methods ${class.java.util.Arrays.asList$3["apple"]["banana"]["orange"]} ${el:staticMethod('java.util.Arrays','asList',3,false)["apple"]["banana"]["orange"]}
Static fields (constants) ${class.java.awt.Color.RED} ${el:staticField('java.awt.Color','RED')}
Constructors ${class.java.new.URL.new$1["http://java.sun.com/"]} ${el:constructor('java.net.URL',1,false)["http://java.sun.com/"]}
Augmented deferred methods action="#{myMap.put$_[aKey][aValue].action}" action="#{el:dynamicMethod(myMap,'put',2,true)[aKey][aValue].action}"

In addition, the following JSP tag is available:

<el:define var="x" value="${rtexpr}" />

For more detail see the expression syntax and tag library description pages.