jsf - Make active component if check box is selected -


i want make active h:selectonemenu when h:selectbooleancheckbox selected.

<h:selectbooleancheckbox value="#{user.rememberme}" /> agree     <h:selectonemenu value="#{user.favcoffee1}">     <f:selectitem itemvalue="cream latte" itemlabel="coffee3 - cream latte" />     <f:selectitem itemvalue="extreme mocha" itemlabel="coffee3 - extreme mocha" />     <f:selectitem itemvalue="buena vista" itemlabel="coffee3 - buena vista" /> </h:selectonemenu> 

in cases let user select value h:selectonemenu when has selected here accepts web site terms.

just bind disabled attribute of other component checkbox value , let checkbox ajax-update other component on change.

<h:selectbooleancheckbox value="#{user.rememberme}">     <f:ajax render="menu" /> </h:selectbooleancheckbox>  <h:selectonemenu id="menu" ... disabled="#{not user.rememberme}">     ... </h:selectonemenu> 

you need make sure managed bean holding property bound disabled (and rendered , readonly) attribute view scoped. see how choose right bean scope?

in case you'd show/hide via rendered attribute instead of enable/disable via disabled attribute, need wrap in component , ajax-update wrapper instead. see why need nest component rendered="#{some}" in component when want ajax-update it?


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -