SelectOneListbox

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

  • Option 1
  • Option 2
  • Option 3
nova-lightNova-Light
nova-darkNova-Dark
nova-coloredNova-Colored
luna-blueLuna-Blue
luna-amberLuna-Amber
luna-greenLuna-Green
luna-pinkLuna-Pink
omegaOmega

Selected Values
Basic:
Advanced:
<style type="text/css">
    .label, .value {
        vertical-align: top
    }

    .output {
        font-weight: bold
    }
</style>


<h:form>
    <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5" columnClasses="label, value">
        <p:outputLabel for="basic" value="Basic:" />
        <p:selectOneListbox id="basic" value="#{selectOneView.option}">
            <f:selectItem itemLabel="Option 1" itemValue="1" />
            <f:selectItem itemLabel="Option 2" itemValue="2" />
            <f:selectItem itemLabel="Option 3" itemValue="3" />
        </p:selectOneListbox>

        <p:outputLabel for="advanced" value="Advanced:" />
        <p:selectOneListbox id="advanced" value="#{selectOneView.theme}" converter="themeConverter" var="t" filter="true" filterMatchMode="contains">
            <f:selectItems value="#{selectOneView.themes}" var="theme" itemLabel="#{theme.displayName}" itemValue="#{theme}" />

            <p:column>
                <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:selectOneListbox>
    </h:panelGrid>

    <p:separator />

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

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

            <h:outputText value="Advanced:" />
            <h:outputText value="#{selectOneView.theme}" />
        </p:panelGrid>
    </p:dialog>
</h:form>