Sometimes you need to display different outputs or components depending on a value. Usually you can achieve this by using the ui:fragment tag.
With the pe:switch util tag you won't have to declare ui:fragment tags, with different checks like ui:fragment rendered="#{!empty someController.value}", anymore.
Source
<p:growl id="growl" showDetail="true" />
<p:selectOneMenu id="caseSelection" value="#{switchController.value}">
<f:selectItem itemLabel="Default case" itemValue="default" />
<f:selectItem itemLabel="Case 1" itemValue="case1" />
<f:selectItem itemLabel="null" itemValue="#{null}" />
<f:selectItem itemLabel="Case 2" itemValue="case2" />
<p:ajax update="swichWrapper" process="@this" />
</p:selectOneMenu>
<p:separator />
<p:outputPanel id="swichWrapper">
<pe:switch id="switch" value="#{switchController.value}">
<pe:defaultCase>
Case: Default
</pe:defaultCase>
<pe:case value="case1">
Case: <p:commandButton id="case1button" actionListener="#{switchController.listener('case1')}" update=":mainForm:growl"
value="Call listener with 'case1'" />
</pe:case>
<pe:case value="case2">
Case: <p:commandButton id="case2button" actionListener="#{switchController.listener('case2')}" update=":mainForm:growl"
value="Call listener with 'case2'" />
</pe:case>
<pe:case value="#{null}">
Case: Null
</pe:case>
</pe:switch>
</p:outputPanel>
@ManagedBean
@RequestScoped
public class SwitchController {
private String value;
public String getValue() {
return value;
}
public void setValue(final String value) {
this.value = value;
}
}