Unified Expression Language and JSF 1.2/2.0

The Unified Expression Language in EE6 is getting updated to support arbitrary/parameterized method calls without having to use static EL functions.

Here's is a quick example.  Consider the following managed bean:
public class TestBean {
    private List<String> names = new ArrayList<String>();

    public String greetName(String name) {
        names.add(name);
        return "Hello, " + name;
    }

    public List<String> getNamesGreeted() {
       return names;
    }
}

and now consider the following fragment from a Facelet view:
<h:outputText value="#{bean.greetName('Bill')}" /><br />
<h:outputText value="#{bean.namesGreeted.size()}" />

The first outputText will display "Hello, Bill", and the second, displays the size of the collection of all the names greeted, which in this simple example, would be "1".

So what about parameterized MethodExpressions (i.e. <h:commandButton action="#{bean.doAction(arg1, arg2)}" ... />)?
Well, this is currently a work in progress by the EL implementation folks.  Stay tuned for updates on this particular topic.

The new EL is already available in GlassFish V3, so if you're using V3 promoted builds, you can start taking advantage of the EL now with JSF and no configuration is necessary.

If you'd like to use the new EL in GlassFish V2, you can, as long as you're not using JSP.  The JSP compiler performs static analysis of the page being compiled and will complain when it encounters parameterized expressions.  This means you'll need to use an alternative view technology such as Facelets.

The EL libraries are available at the following URLs:
Copy the two JAR files to ${GLASSFISH_HOME}/lib, then edit ${GLASSFISH_HOME}/domains/<domain_name>/config/domain.xml and add the following attribute to the java-config element:
classpath-prefix="${com.sun.aas.installRoot}/lib/el-api-2.1.2-SNAPSHOT.jar:${com.sun.aas.installRoot}/lib/el-impl-2.1.2-SNAPSHOT.jar"
If the classpath-prefix attribute has already been defined, then append these two jars after the existing entries.  This modification will require a restart of the domain.  After these steps are complete, you should be able to leverage the new EL features.

Lastly, I'd recommend reviewing the change log for the new expression langauge to get familiar with what it offers and its limitations.
Comments:

Post a Comment:
Comments are closed for this entry.
About

user12615560

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today