Theme
arya
luna-amber
luna-blue
luna-green
luna-pink
nova-dark
nova-light
saga
vela
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:switch
Attributes (move mouse over the names to see data types)
Name Description
id Unique identifier of the component in a namingContainer.
rendered Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding An EL expression referring to a server side UIComponent instance in a backing bean.
value Value of the component.
PrimeFaces Extensions Showcase - © 2011-2023,PrimeFaces: 13.0.0,PrimeFaces Extensions: 13.0.1,JSF: Apache MyFaces JSF-2.3 Core Impl 2.3.10,Server: jetty/9.4.36.v20210114,Build time: 2023-09-11 19:07