In my application I have three dropdown menu (p:selectOneMenu
), say A, B, C. Among them two are dependent, say B and C. By changing the value of B I am dynamica
You can use EL in the required
attribute. You can let the desired expression evaluate true
only when a particular submit button is pressed, or when a particular component value is submitted (and thus by its client ID present in the request parameter map #{param}
).
The following kickoff example should do what you need.
<p:selectOneMenu binding="#{menu1}" ... required="#{not empty param[submit.clientId]}">
...
</p:selectOneMenu>
<p:selectOneMenu ... required="#{not empty param[menu1.clientId]}">
...
</p:selectOneMenu>
<p:commandButton binding="#{submit}" ... />
This way, the 1st menu is only required when the form's main submit button is pressed (and thus not when event listeners are fired) and the 2nd menu is only required when the 1st menu has a value.