+ Start a Discussion
AveleenaAveleena 

Re render issue

Hi,

 

I am facing a rerender issue. It will be great if any one can help me out.

I have checkbox on my visualforce page, on clicking on the checkbox all the addeess info from the above fields needs to be copied over to the below fields. All the below fields are required, due to which the action function does not get called and i get the required field error on my page.

 

Is there any way i can handle this required field error and copy over the fields instead?

Any ideas will be of great help.

 

Thanks in advance!

Best Answer chosen by Admin (Salesforce Developers) 
Avidev9Avidev9

Well this is a common problem which people face with rerender. The Solution not very difficult. So what you have to do is selectively submit your VF page. 

 

To do so wrap the section from where you want to copy the data/fields into the secondary field using a actionRegion

 

<apex:actionRegion>

      <apex:actionFunction name="onCheckBoxClick" rerender="DestinationSectionId"

      <apex:inputCheckbox........

     <!-- Address fields to copy --->

</apex:actionRegion>

All Answers

Avidev9Avidev9

Well this is a common problem which people face with rerender. The Solution not very difficult. So what you have to do is selectively submit your VF page. 

 

To do so wrap the section from where you want to copy the data/fields into the secondary field using a actionRegion

 

<apex:actionRegion>

      <apex:actionFunction name="onCheckBoxClick" rerender="DestinationSectionId"

      <apex:inputCheckbox........

     <!-- Address fields to copy --->

</apex:actionRegion>

This was selected as the best answer
Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Hi,

 

To show the required fields based on the checkbox selection you can use actionsupport in the checkbox field.

 

Try the following example,

 

<apex:page standardcontroller="Account" extensions="checkboxRenderController">  
  <apex:form >
    <apex:pageblock>
      <apex:pageblocksection>        
         <apex:actionregion>
             <apex:outputlabel value="Copy Address1"/>
              <apex:inputfield value="{!Account.checkbox1__c}">
                   <apex:actionsupport event="onclick" rerender="theblock"/>
              </apex:inputfield >
         </apex:actionregion>
         
         <apex:outputpanel id="theblock">
              <apex:outputlabel value="Phone" rendered="{!Account.checkbox1__c == false}"/>
              <apex:outputtext value="{!Account.Phone}" required="false" rendered="{!Account.checkbox1__c == false}"/>
              <apex:outputlabel value="Phone" rendered="{!Account.checkbox1__c == true}"/>
              <apex:inputfield value="{!Account.phone}"  required="true"  rendered="{!Account.checkbox1__c == false}"/>
         </apex:outputpanel>
     </apex:pageblocksection>   
    </apex:pageblock>
  </apex:form>  
</apex:page>

 

Here, i have a checkbox field in Account object named 'Checkbox1__c'. If i select this checkbox then phone field will be mandatory, if i deselect it then it will become not required.

 

Hope this will help you...!

 

Please don't forget to give kudos and mark this as a solution, if this works out.

GangulyGanguly

Hi Avidev,

 

I am facing a similar issue. I also had this solution in mind. But the problem is, i have 25 different sections, where i have different action regions and command links respectively. So, writing 25 different Action Functions for the sections is not a good idea according to me. 

 

So is there some other approaches to resolve this? Please help me out in this case.

 

Thanks,

Kaushik

Avidev9Avidev9
You can use action:Support instead of actionFunction