SelectOneMenu

SelectOneMenu is used to choose a single item from a list.

Values
Basic:
Grouping:
Editable
Advanced:
Lazy:
<style type="text/css">
    .value {
        font-weight: bold;
    }
</style>


<h:form>
    <p:messages>
        <p:autoUpdate />
    </p:messages>

    <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
        <p:outputLabel for="console" value="Basic:" />
        <p:selectOneMenu id="console" value="#{selectOneMenuView.console}" style="width:125px">
            <f:selectItem itemLabel="Select One" itemValue="" />
            <f:selectItem itemLabel="Xbox One" itemValue="Xbox One" />
            <f:selectItem itemLabel="PS4" itemValue="PS4" />
            <f:selectItem itemLabel="Wii U" itemValue="Wii U" />
        </p:selectOneMenu>

        <p:outputLabel for="car" value="Grouping: " />
        <p:selectOneMenu id="car" value="#{selectOneMenuView.car}">
            <f:selectItem itemLabel="Select One" itemValue="" />
            <f:selectItems value="#{selectOneMenuView.cars}" />
        </p:selectOneMenu>

        <p:outputLabel for="city" value="Editable: " />
        <p:selectOneMenu id="city" value="#{selectOneMenuView.city}" effect="fold" editable="true">
            <f:selectItem itemLabel="Select One" itemValue="" />
            <f:selectItems value="#{selectOneMenuView.cities}" />
        </p:selectOneMenu>

        <p:outputLabel for="advanced" value="Advanced:" />
        <p:selectOneMenu id="advanced" value="#{selectOneMenuView.theme}" converter="themeConverter" panelStyle="width:180px"
                         effect="fade" var="t" style="width:160px" filter="true" filterMatchMode="startsWith">
            <f:selectItems value="#{selectOneMenuView.themes}" var="theme" itemLabel="#{theme.displayName}" itemValue="#{theme}" />

            <p:column style="width:10%">
                <h:graphicImage name="showcase/images/themeswitcher/themeswitcher-#{t.name}.png" alt="#{t.name}" styleClass="ui-theme" />
            </p:column>

            <p:column>
                <h:outputText value="#{t.displayName}" />
            </p:column>
        </p:selectOneMenu>

        <p:outputLabel for="lazy" value="Lazy:" />
        <p:selectOneMenu id="lazy" value="#{selectOneMenuView.option}" dynamic="true" style="width:125px">
            <f:selectItem itemLabel="Select One" itemValue="" />
            <f:selectItems value="#{selectOneMenuView.options}" />
        </p:selectOneMenu>
    </h:panelGrid>

    <p:commandButton value="Submit" update="display" oncomplete="PF('dlg').show()" icon="pi pi-check" />

    <p:dialog header="Values" modal="true" showEffect="bounce" widgetVar="dlg" resizable="false">
        <p:panelGrid columns="2" id="display" columnClasses="label,value">
            <h:outputText value="Basic:" />
            <h:outputText value="#{selectOneMenuView.console}" />

            <h:outputText value="Grouping:" />
            <h:outputText value="#{selectOneMenuView.car}" />

            <h:outputText value="Editable" />
            <h:outputText value="#{selectOneMenuView.city}" />

            <h:outputText value="Advanced:" />
            <h:outputText value="#{selectOneMenuView.theme.displayName}" />

            <h:outputText value="Lazy:" />
            <h:outputText value="#{selectOneMenuView.option}" />
        </p:panelGrid>
    </p:dialog>
</h:form>