arya-blue
luna-amber
luna-blue
luna-green
luna-pink
nova-dark
nova-light
saga-blue
vela-blue
Switch
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.

Case: Default
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>
            
Components and more
Documentation pe:
Attributes (move mouse over the names to see data types)
Name Description
No attributes available for this component.
PrimeFaces Extensions Showcase - © 2011-2025,PrimeFaces: 15.0.13,PrimeFaces Extensions: 15.0.14-SNAPSHOT,JSF: Apache MyFaces JSF-2.3 Core Impl 2.3.10,Server: Apache Tomcat (TomEE)/9.0.82 (8.0.16),Build time: 2026-02-23 00:32