Showing posts with label EL. Show all posts
Showing posts with label EL. Show all posts

21 June 2012

Expression Language 3.0 is in public review

The Expression Language (EL) is widely used in JSP and JSF. With version 3 the EL now becomes an independent specification. The EL v3 (JSR 314) is in public review until the end of July. It will be released in sync with Java EE 7 (Update: EL 3.0 was released in may 2013). New features include:

  •  As an independent specification, EL now comes with a standalone API, allowing usage outside a web container.
    • You can write your own ELProcessor. The source code is available, but I wish they had put the javadoc for  browsing at the project site as well.
  • Java 8 stuff
    • Lambda expressions
    • Collection literals follow proposed Java 8 syntax
      • List: [1, "two", 3.0]
      • Set: {1, 2, 3}
      • Map: {"one":1, "two":2, "three":3}
    • Collection streaming
  • Assignment operator (=) for changing values:
    • ${customer.name = 'Jan'}
  • String concatenation: + or cat operator
    • ${‘Welcome ‘ += customer.name += ‘ to our site’}.
  • Support for static references using the T construct (Type). 
    • By default only java.* and javax.* packages are available, but you can modify this using the EL API.
      • ${T(java.util.Calendar).APRIL}
      • ${T(java.util.Calendar).getInstance()}
    •  You can call constructors as a static method without a name. To call the default Calendar constructor:
      • ${T(java.util.Calendar).()}
    • For java.lang you can use the class without using the T construct
      • ${Boolean.TRUE}

16 May 2010

JSTL/JSP EL alternate Struts excercise solution

The De Post/PMC excercises (and the Struts blank sample application) are based on

  • Struts
    • tags-bean
    • tags-logic
    • tags-html
  • JSP scriptlets
In this post we will show how to move this to
  • Struts
    • tags-html
  • JSTL
  • JSP expression language
To enable JSTL/JSP/EL support in your application follow these instructions. Here’s the table from the excercise rendered with JSTL/JSP EL:
<c:forEach  var="product" items="${List}"  varStatus ="status">
  <tr class="${(status.index%2==1)?'odd':'even'}">
    <td>
      <html:link action="<%=modify%>" paramId="id" paramName="product" paramProperty="id">
        <html:img srcKey="icon.edit" altKey="icon.alt.edit" border="0"/>
      </html:link> 
    </td> 
    <td>
      <html:link action="<%=remove %>" paramId="id" paramName="product" paramProperty="id">
        <html:img srcKey="icon.trash" altKey="icon.alt.trash" border="0"/>
      </html:link>
    </td>
    <td> ${product.name}</td> 
    <td> ${product.description}</td>
  </tr>
</c:forEach>