Primefaces : How to do selectOne without value to select ?

If you wan’t use list components and want have a select itens without value you can use this:

<f:selectItem itemLabel="Select one ..." itemValue=""
              noSelectionOption="true"/>

Example

<p:selectOneMenu value="#{myController.objectSelected}"
                 converter="genericEntityConverter">
    <f:selectItem itemLabel="Select one" itemValue=""
                  noSelectionOption="true"/>
    <f:selectItems value="#{myController.takeAllObjects()}"
                   var="o"
                   itemLabel="#{o.name}"
                   itemValue="${o}">
    </f:selectItems>
</p:selectOneMenu>

You can use this to pass other values that you don’t have in the list too.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s