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:divider />

<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:switch
Attributes (move mouse over the names to see data types)
Name Description
bindingAn EL expression referring to a server side UIComponent instance in a backing bean.Default is generated.
idUnique identifier of the component in a namingContainer.Default is generated.
renderedBoolean value to specify the rendering of the component, when set to false component will not be rendered.Default is true.
valueThe value to compare against case values to determine which case to render.
PrimeFaces Extensions Showcase - © 2011-2025,PrimeFaces: 16.0.0-SNAPSHOT,PrimeFaces Extensions: 16.0.0-SNAPSHOT,JSF: Apache MyFaces Core 4.0 - Impl 4.0.3,Server: Apache Tomcat (TomEE)/10.1.52 (10.1.4),Build time: 2026-03-10 11:37