I have the following selectOneMenu and within of my component I want to have an item which shouldn't be shown, for e.g. in cases where the value from #{Mybean.value} match a value from #{Mybean.ListValues} I don't want to have an empty option in my combo box .
<p:selectOneMenu value="#{Mybean.value}" hideNoSelectionOption="true"
required="true" requiredMessage="Required data">
<f:selectItem itemLabel="" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems value="#{Mybean.ListValues}" var="option" itemLabel="#{option.optionName}"
itemValue="#{option.optionId}"/>
</p:selectOneMenu>
I searched, but I didn't find anything useful, just one link in primefaces forum where describes exactly this problem.
My primefaces version is 3.5
Edit: it is supported from version 9 and on, see the other answer.
That attribute doesn't exist in the official api or in the doc. Where did you get it from?
What you're actually looking for is the itemDisabled
attribute on the f:selectItems
component. It's this attribute that disables a selectItem from being selected. Historically, primefaces has had problems with that attribute.
Ideally, you should have
<p:selectOneMenu value="#{Mybean.value}" required="true" requiredMessage="Required data">
<f:selectItem itemLabel="" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems itemDisabled="#{Mybean.value=='aValue'}" value="#{Mybean.ListValues}" var="option" itemLabel="#{option.optionName}" itemValue="#{option.optionId}"/>
</p:selectOneMenu>