I have the next code:
<p:selectOneMenu id="select1" value="#{bean.select1}">
<f:selectItem itemValue="#{null}" itemLabel="--SELECT--" />
<f:selectItems value="#{bean2.data}" var="data" itemValue="#{data.value}" itemLabel="#{data.label}/>
<p:ajax process="@this" update="select2" />
</p:selectOneMenu>
<p:selectOneMenu id="select2" value="#{bean.select2}" disabled="#{bean.select1 == null}">
<f:selectItem itemValue="#{null}" itemLabel="--SELECT--" />
<f:selectItems value="#{bean2.getData(bean.select1)}" var="data" itemValue="#{data.value}" itemLabel="#{data.label}/>
</p:selectOneMenu>
My problem is the next:
- I choose in “select1” a value, and then it updates “select2” with the list of values.
- I choose in “select2” a value, for example “VALUE1”.
- I submit the form.
- I choose in “select1” the value “–SELECT–“, and then it updates “select2” leaving it disabled with the value “–SELECT–“
- If I submit the form again, I get in my backbean these values:
select1 == NULL
andselect2 == VALUE1
.
I guess the issue here is that my “select2” is disabled, so that’s why when I submit the form it isn’t submmiting the value NULL. Is it possible to achieve this without using a listener on select1 to clean the backbean value attached to the select2?
In this example I have only 2 selectOneMenu, but in my real case I have multiple selectOneMenus in a chain, and cleaning them with a listener seems very tedious.
Ideas?
I’m using JSF 4.1, Primefaces 14 and Omnifaces 4.4.1
Thanks.