HTML and CSS Reference
In-Depth Information
page rendering (NOT the page postback) because they are evaluated once the page is rendered for the first time. This
means that the JSP EL is always read-only value expressions, while the JSF EL can work in both read and write modes.
Unified Expression Language
Thanks to JSP 2.1, which was part of the Java EE 5, this mismatch is resolved by having a unified EL which essentially
represents a union of the JSP and JSF ELs. The unified EL has the following features:
Deferred evaluations of expressions.
The expressions can work in both read and write modes.
Listing 2-15 shows an example that shows how the <c:forEach> JSTL tag can work with the JSF deferred
expression #{..} .
The JSTL tags can work with deferred expressions.
Listing 2-15. The JSF Deferred Expressions with the <c:forEach> Tag
<b>You have the following initial list of favorite sports:</b>
<ul>
<c:forEach items="#{user.favoriteSport}" var="sport">
<li>#{sport}</li>
</c:forEach>
</ul>
As shown in the listing, this code can be a replacement for the code in Listing 2-16, which is part of the
welcome.xhtml page in the firstApplication .
Listing 2-16. The Original JSF Deferred Expression with the <ui:repeat> Tag
<b>You have the following initial list of favorite sports:</b>
<ul>
<ui:repeat value="#{user.favoriteSport}" var="sport">
<li>#{sport}</li>
</ui:repeat>
</ul>
Adding to this, you have the option to combine other JSTL tags with the JSF deferred expressions, as shown in
Listing 2-17.
Listing 2-17. The JSF Deferred Expressions with the Different JSTL Tags
<b>You have the following initial list of favorite sports:</b>
<ul>
<c:forEach items="#{user.favoriteSport}" var="sport">
<c:choose>
<c:when test="#{sport == 'Football'}">
<li><b><u>Popular in Africa:</u></b> #{sport}</li>
</c:when>
<c:otherwise>
<li>#{sport}</li>
</c:otherwise>
</c:choose>
</c:forEach>
</ul>
 
Search WWH ::




Custom Search