We are glad to introduce the new generation expression language of Java EE 7 – Expression Language 3 (EL 3) into ZK 8 so we can do more complicated and more powerful things with the newer expression language. There are many new features in EL 3 such as new operators, lambda expressions, collection operations etc. For more details, you can check the EL 3 specification, JSR-341. Next, we will go through some new features with some sample code and demo in this post.
It’s a simple application for users to convert lengths into different units, and for selecting different display names. In this application, we only need to provide a getter and setter in the composer or MVVM just like how you would handle a POJO. The formula used to convert the units are all coded in the ZUL which EL 3 takes cares of for developers.
In the demo’s application header, there are some greetings, the corresponding zul looks like the following
A static field or static method of a Java class can be referenced with the syntax Classname.Field, such as
<label value="@load((Math.sqrt(16)))" />
Note that java.lang.* is imported by default.
Now we know the capability of expression language 3, from commonly used string concatenation to complex stream operations, EL 3 can do much more than we can imagine. We can keep our composer or view model focus on the business logic while leave the trivial tasks to view. Moreover, the runtime of JVM is backward compatible to JDK 1.5, including lambda expression and collection operations.