Let the source component ajax-update the target component on the desired events, and let the disabled
attribute of the target component check if the value
of the source component is not empty
.
So,
<p:calendar ... value="#{bean.date}">
<p:ajax event="valueChange" update="menu" />
<p:ajax event="dateSelect" update="menu" />
</p:calendar>
...
<p:selectOneMenu id="menu" ... disabled="#{not empty bean.date}" />
The binding
is not necessary in this construct. If you really want to use it, then you should be checking the component's value
attribute, not the component itself (which is obviously never null
).
<p:calendar binding="#{calendar}" ...>
<p:ajax event="valueChange" update="menu" />
<p:ajax event="dateSelect" update="menu" />
</p:calendar>
...
<p:selectOneMenu id="menu" ... disabled="#{not empty calendar.value}" />
If you want to learn more about binding
, head to How does the 'binding' attribute work in JSF? When and how should it be used?