reRender checkboxes problem

I have a menu (screen below) where the two section are refreshed using rerender.
Depending to main object the sections are refreshed. The input checkboxes checked for the 1st main object are deleted when I change the main object.
Is there a way to keep the boxes checked after rerendring ?

enter image description here


Here is the sections that I reRender and to get the boxes checked I use JS and onclick event.


    <apex:pageBlock >
        <apex:pageBlockSection id="sec2Title" title="Select Child Object" />
        <ul class="filetree treeview" id="browser">
            <apex:form >
                <apex:outputPanel id="objChildren">
                    <ul id="boxesChildObj">
                        <apex:repeat value="{!children}" var="s">
                            <input type="checkbox" class="{!s}" /> <label id ="{!s}"  onclick="childToFields(;" style="cursor:pointer;"> {!s} </label> <br/>


The result for 3 fields for example is :

enter image description here


To keep checkboxes checked/unchecked after rerender you will have to store their checked value somewhere in the code of your controller.

And every time you check/uncheck a checkbox you will have to update those values in your code as well. For checkbox you can then use:

<apex:inputCheckbox selected="{!yourMethodThatReturnsIfCheckboxShouldBeSelected}"/>

Source : Link , Question Author : Amine Darkaoui , Answer Author : Novarg

Leave a Comment