How to submit form, from p:selectBooleanCheckbox change event
ajax, jsf-2, primefaces
Solution
Just make sure that you update only the section which really needs to be updated.
<p:selectBooleanCheckbox id="checkBox1" value="#{bbean.someBoolValue}" >
<p:ajax event="change" update="hiddingPanel" />
</p:selectBooleanCheckbox>
<!-- some input fields here. These will be rendered depending checkBox1 value -->
<p:panel id="hiddingPanel">
<h:panelGrid columns="2" rendered="#{bbean.someBoolValue}">
<p:inputText id="input3" />
</h:panelGrid>
</p:panel>
Note that I moved `rendered` to its immediate child, for the reasons explained here: Why do I need to nest a component with rendered="#{some}" in another component when I want to ajax-update it?
Problem
I'm using primefaces and working on a complex form. I need to hide a part of the form, depending on the value of a checkbox ``` <p:selectBooleanButton id="input1" .... /> <p:inputText id="input2" /> <!-- the boolean checkbox --> <p:selectBooleanCheckbox id="checkBox1" value="#{bbean.someBoolValue}" > <p:ajax event="change" update=":#{p:component('someParentcComponentsId')}" /> </p:selectBooleanCheckbox> <!-- some input fields here. These will be rendered depending checkBox1 value --> <p:panel rendered="#{bbean.someBoolValue}" id="hiddingPanel"> <h:panelGrid columns="2" > <p:inputText id="input3" /> </h:panelGrid> </p:panel> ``` So far, I've made that work, so when `checkBox1` is clicked, `hiddingPanel` is getting shown or hidden. But there's a catch: the values of every input in that form ( e.g. `input1`, `input2` ) are lost, since the 'change' ajax event is not submitting their values. How could I make sure that all input values are submitted before updating the form ?