How to communicate back and forth between client and server-side in JSF? -


most of problems in jsf, far, seem boil down - communication (static) client-side (dynamic) server-side, , vice-versa; instance, re-rendering components.

an example: enabling/disabling button (commandbutton) depends on selection of selectoneradio.

what correct way communicate selection of selectoneradio (client server) , ajaxingly updating commandbutton (server client)?

by using <f:ajax>.

here's example enables button when second item selected.

<h:selectoneradio value="#{bean.selecteditem}">     <f:selectitem itemvalue="1" itemlabel="first item" />     <f:selectitem itemvalue="2" itemlabel="second item" />     <f:ajax render="button" /> </h:selectoneradio> <h:commandbutton id="button" disabled="#{bean.selecteditem != 2}" /> 

make sure #{bean} @viewscoped 1 state remembered across postbacks. else it'll fall default values when press submit button.


that said, recommend go through decent jsf book. above covered in 1st chapter.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -