5

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

EDIT

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(this.id);" style="cursor:pointer;"> {!s} </label> <br/>
                        </apex:repeat>
                    </ul>    
                </apex:outputPanel>

            </apex:form>
        </ul>
    </apex:pageBlock>

The result for 3 fields for example is :

enter image description here

  • Can you share some code snippets? Specifically what are the parts of your page you are refreshing, what Apex code is being triggered on the reRender, and what construct are you using in your controller to store the checkbox state (wrapper class)? – pchittum Nov 26 '14 at 11:24
  • @Peter I shared some code parts. – Amine Darkaoui Nov 26 '14 at 11:44
  • 2
    @AmineDarkaoui know that stackexchange sites are not like other forums or websites. Answers are only intended for full answers to your question, not to be used as replies. This is why Novarg moved your earlier post to an update in your question, and I have deleted your answer (which was a reply.) We're here to help! – Samuel De Rycke Nov 26 '14 at 13:33
2

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}"/>
  • thank you. I already store the the fields and the objects in a map with JS For exemple ---> Object {Account: Array[3]}Account: Array[3] 0: "AnnualRevenue"1: "BillingAddress"2: "BillingCountry" length: 3. The problem is can I have something that notify me that the rerender is finished – Amine Darkaoui Nov 26 '14 at 11:34
  • @AmineDarkaoui I'm not aware of anything that will notify you when reRender is finished. Normally reRender happens instantly – Novarg Nov 26 '14 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.