I am facing a strange problem. Actually few of my form fields visibility depends on picklist selected data. for example If i select "Yes" in Previously_Applied__c picklist then "Previously_Applied_When__c" input field should be displayed.

I have implemented the same (have pasted code below) but when i select "Yes" in Previously_Applied__c picklist "Previously_Applied_When__c" input field get displayed but i lost all form data(form fields sets to their default).

Plz suggest me How can i resolve this.

        <apex:pageBlockSection title="Academic Interests" columns="2" collapsible="false" id="academic">            
           <apex:repeat value="{!applicationFields}" var="f">  

           <apex:inputField value="{!applicationDetails[f]}" required="{!OR(f.required,f.dbrequired)}" 
                    rendered="{!(f != 'Previously_Applied__c' && f != 'Previously_Applied_When__c')}" />              

        <apex:pageBlockSectionItem rendered="{!(f == 'Previously_Applied__c')}">
                    <apex:outputLabel value="Have you applied to Utica College before?"/>
                    <apex:actionRegion >
                        <apex:inputField value="{!applicationDetails[f.fieldpath]}" required="{!OR(f.required,f.dbrequired)}">
                             <apex:actionSupport event="onchange"  rerender="academic"/>

                <apex:pageBlockSectionItem rendered="{!(f == 'Previously_Applied_When__c' && applicationDetails.Previously_Applied__c == 'Yes')}">
                        <apex:outputLabel value="When did you previously apply?" />
                        <apex:inputField required="{!OR(f.required,f.dbrequired)}" value="{!applicationDetails[f]}" />


3 Answers 3


You are using an apex:actionRegion and the fields that have their data "lost" on the rerender are outside of the action region.

The server will only process what is within the actionRegion when the onchange triggers an ajax request to the server. If you have fields on the page that the user can change in a section of the page that is rerendered as part of the onchange then you have to include them in the actionRegion so that they are processed. If they aren't included, the server won't know about them and when the section they are in is rerendered it will appear as if they are lost.

  • Thanks peter for your reply. Peter i used apex:acitonFunction instead of apex:actionSupport and my problem is resolved. I think actionFuction submit entire page to server. Am i right? Jan 19, 2013 at 16:57
  • @PramodKumar - No. You can use actionRegion and actionFunction together; however the docs specify that actionFunction is not supported inside of an iteration component as of API version 23, so you probably moved it outside of the actionRegion which would have the effect of submitting more than what is in the actionRegion. (BTW, I think it submits the whole form anyway, based on my examination of the HTTP request, but the actionRegion just limits what/how it is processed). Jan 19, 2013 at 19:57
  • @PramodKumar - To be clear, what matters when working with the actionFunction and actionRegion together is where the actionFunction element is located. If it is inside of the actionRegion then just what's inside of the actionRegion will be processed, even if the actionFunction is invoked from outside of the actionRegion. However, if the actionFunction is defined outside of the actionRegion and and is invoked from within the actionRegion the actionRegion makes no difference. It's all about where the actionFunciton element is located. (btw, Glad you were able to get by your issue!!!) Jan 19, 2013 at 20:10

Peter and Mathew have explained this better to you and here is my thought. 1. On the onchange event, you are refreshing the whole table which will wipe out all your form data or the values selected by the user. 2. So what you want to do is expand your action region section and put all the input fields inside the action region. 3. Before you render academic, create a handler method in your controller and call that method in your event. On the handler method what ever you call, read all the input values and store them to a list and when you rerender it display it back. I think you need to restructure the page a bit to do this. Thanks Buyan

  • If the action:region is expanded shouldn't all of the properties within it retain their value when reRendered without any extra work of storing values in a separate List, etc, as long as they aren't transient properties? Jan 19, 2013 at 15:29

The issue seems to be occurring because you are rerendering the apex:repeat with rerender="academic" on the apex:actionSupport. When the repeat is rerendered, all of the data within is refreshed (and therefore the data appears to be "lost").

To fix this, there are two options.

  1. Save the record before rerendering. You should be able to do this by adding the action="{!save}" (or another action in your controller that saves the record) attribute to the actionSupport.
  2. Restructure the page so that you can render only a few fields included in the apex:repeat.
  • I can't save the record before rendering and i will have to use apex:repeat to iterate list of all application fields. Jan 16, 2013 at 16:33
  • I will have to use fieldset and to iterate fieldset i will have to use repeat Jan 16, 2013 at 16:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .