So I've been working with JSTL, JSF and Facelets for a while now and didn't come across a decent post on how to default values or work with legacy varibles (i.e. you had renamed your f:param to a component).
The solution is to use a combination of c:if and c:set tags, like the following:
<c:if test="#{empty optionalVar}">
<c:set var="optionalVar" scope="page" value="#{defaultValue}"/>
</c:if>
<!-- or -->
<c:if test="#{empty newVarName}">
<c:set var="newVarName" scope="page" value="#{oldVarName}"/>
</c:if>
This has been working great for me. I've been digging around for decent articles on how else f:param and f:attributes are used and found a great one called Communication in JSF.
No comments:
Post a Comment