Find JSRs
Submit this Search


Ad Banner
 
 
 
 

JSR 052 • JavaServer Pages™ (JSP™) Standard Tag Library (JSTL)
Maintenance Review 2 (JSTL 1.2)

Description

Second maintenance review of the JavaServer Pages™ (JSP™) Standard Tag Library (JSTL 1.2).

Maintenance Lead

Pierre Delisle, Sun Microsystems, Inc.

Feedback

Comments should be sent to jsr-52-comments@jcp.org

Rationale for proposed changes

The goal of this maintenance release is to align the JSTL specification with the work done on the JavaServer Pages 2.1 and JavaServer Faces (Faces) 1.2 specifications. Also, as of this release (JSTL 1.2), JSTL is now part of the Java Enterprise Edition platform.

Proposed Changes

1. Iteration tags support for nested actions with deferred-values referring to the iteration variable

The semantics of the standard actions <c:forEach> and <c:forTokens> are modified to allow the iteration tags to work seamlessly with nested JavaServer Faces actions.

More specifically, <c:forEach> and <c:forTokens> now support nested actions with deferred-values referring to the iteration variable, as long as a deferred value has been specified for the 'items' attribute.

For example:

  <c:forEach var="item" items="#{model.list}">
    <h:inputText value="#{item.name}"/>
  </c:forEach>
Changes:
  • In the core library TLD, attribute 'items' of <c:forEach> and <c:forTokens> now accept both runtime expressions and deferred-values.
  • When a deferred-value is specified for the 'items' attribute, the tag handler now adds at each iteration a mapping for the 'var' attribute into the EL VariableMapper.
Below are some implementation notes illustrating how an iteration tag handler may process a deferred-value specified for the 'items' attribute.
  doStartTag()
     ...
     // 'items' is a deferred-value
     // Get the current EL VariableMapper
     VariableMapper vm = jspContext.getELContext().getVariableMapper();

     // Create an expression to be assigned to the variable specified
     // in the 'var' attribute.
     // 'index' is an iteration counter kept by the tag handler.
     myimpl.IndexedExpression expr = new myimpl.IndexExpression(getItems(), index);

     // Assign the expression to the variable specified in the 'var' attribute,
     // so any reference to that variable will be replaced by the expression 
     // in subsequent EL evaluations.
     oldMapping = vm.setVariable(getVar(), expr);
     ...


   doEndTag() 
     ...
     // restore the original state of the VariableMapper:
     jspContext.getELContext().getVariableMapper().setVariable(getVar(), oldMapping);
     ...

The number of items referred to by the "items" attribute must be the same when JSF creates the component tree and when JSP executes the iteration tag. Undefined behavior will result if this is not the case.

2. <c:set> support for deferred values

The semantics of the standard action <c:set> have been modified to allow the action to accept a deferred-value.

For example:
  <c:set var="d" value="#{handler.everythingDisabled}"/>
  ...
  <h:inputText id="i1" disabled="#{d}"/>
  <h:inputText id="i2" disabled="#{d}"/>
Changes:
  • In the core library TLD, attribute "value" of c:set now accepts both runtime expressions and deferred-values.
  • If a deferred-value is specified, the scope must be "page".
  • When a deferred-value is specified for the "value" attribute, the tag handler now adds a mapping for the "var" attribute into the EL VariableMapper.
Below are some implementation notes illustrating how the <c:set> tag handler may process a deferred-value specified for the "value" attribute.
   doStartTag()
     ...
     // 'value' is a deferred-value
     // Get the current EL VariableMapper
     VariableMapper vm = jspContext.getELContext().getVariableMapper();

     // Assign the expression to the variable specified in the 'var' attribute,
     // so any reference to that variable will be replaced by the expression 
     // in subsequent EL evaluations.
     vm.setVariable(getVar(), (ValueExpression)getValue());
     ...

3. Generics

  • Since JSP 2.1 requires J2SE 5.0, we’ve modified the APIs that can take advantage of generics. These include: ScriptFreeTLV:setInitParameters().

4. Minor corrections

  • Example involving <fmt:parseDate> in section 9.9 was incorrect. A pattern has been added so the date can be parsed properly.
  • Clarified the fact that the output of <c:url> won’t work for the url attribute value of <c:import> for context relative URLs (URLs that start with a '/'). (section 7.4)