JSF Showcase
c:choose
The JSF runtime includes c:choose implementation of the JSTL<c:choose>
JSP tag. If JSTL sounds familiar (heavily used in JSP) then, it provides the same features for JSF too.
General Usage
Use together with c:when and c:otherwise to choose which portion of code will be rendered depending in a condition that can be set intest
attribute from c:when tag handler.
Disabled
Source Code
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://xmlns.jcp.org/jsp/jstl/core" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> <c:choose> <c:when test="#{jSTLBackingBean.rendered}"> Enabled </c:when> <c:otherwise> Disabled </c:otherwise> </c:choose> </ui:composition>
@ManagedBean @RequestScoped public class JSTLBackingBean { private boolean rendered; public boolean isRendered() { return rendered; } public void setRendered(boolean rendered) { this.rendered = rendered; } public void toggleRendered(ActionEvent event) { this.rendered = !rendered; } }
Liferay Faces Bridge Implementation 5.0.0 + Showcase Common 3.1.1 + Liferay Faces Util 3.4.1 + Mojarra 2.2.20