Tuesday, September 13, 2011

Rerender using Action Support in Visualforce pages

There are many instances when it looks simple that a component needs to be displayed only when there is a specific value in a picklist.

We tend to use actionsupport and rerender for such cases where we use actionsupport for some event like onchange or onclick etc and rerender to a specific component.

But many times we find that the rerender is not working properly and we need to struggle around for getting it work.

So it is necessary to understand this when you are using rerender for a component that has rendered attribute

If the component has a rendered attribute then wrap it with outputPanel or pageBlockSection or any other component and rerender to this wrapped component rather than the component that is rendered.

A simple example :

You want to render a field reason lost only when the Opportunity stage is Closed Lost

 <apex:page standardController="Opportunity" sidebar="false">  
   <apex:sectionHeader title="Edit Opportunity" subtitle="{!opportunity.name}"/>  
   <apex:form >  
     <apex:pageBlock title="Edit Opportunity" mode="edit">  
       <apex:pageMessages />  
       <apex:pageBlockButtons >  
         <apex:commandButton value="Save" action="{!save}"/>  
         <apex:commandButton value="Cancel" action="{!cancel}"/>          
       </apex:pageBlockButtons>  
       <apex:actionRegion >  
         <apex:pageBlockSection title="Basic Information" columns="1">  
           <apex:inputField value="{!opportunity.name}"/>  
           <apex:pageBlockSectionItem >  
             <apex:outputLabel value="Stage"/>  
             <apex:outputPanel >  
               <apex:inputField value="{!opportunity.stageName}">  
                 <apex:actionSupport event="onchange" rerender="thePanel"  
                           status="status"/>  
               </apex:inputField>  
               <apex:actionStatus startText="applying value..." id="status"/>  
             </apex:outputPanel>  
           </apex:pageBlockSectionItem>  
           <apex:inputField value="{!opportunity.amount}"/>  
           <apex:inputField value="{!opportunity.closedate}"/>  
         </apex:pageBlockSection>  
       </apex:actionRegion>  
       <apex:outputPanel id=”thePanel”>        
          <apex:pageBlockSection title="Closed Lost Information" columns="1"  
                   rendered="{!opportunity.stageName == 'Closed Lost'}">  
         <apex:inputField value="{!opportunity.Reason_Lost__c}"/>  
       </apex:pageBlockSection>  
      </apex:outputPanel>  
     </apex:pageBlock>  
   </apex:form>  
 </apex:page>  


refer this link from community actionSupport rerender problem for details.

Hope this will help you if you are struggling with action support rerender issues.

Also many times due to Output Panel, fields will be distorted:
Try using outputPanel inside pageBlockSection.
Ex:
 <apex:pageBlockSectionItem >  
 <apex:outputpanel id="panel 1">  
 <apex:outputLabel value="LabelName" rendered="{!oppty.field== 'Other'}"/>  
  </apex:outputpanel>  
  <apex:outputpanel id="panel 2">  
 <apex:inputfield value="{!field}" rendered="{!oppty.field == 'Other'}" />  
 </apex:outputpanel>  
 </apex:pageBlockSectionItem>  

32 comments:

vasudha dharani said...

Salesforce Admin Online Training - 21st Century Software ...
www.21cssindia.com/courses/salesforce-admin-online-training-143.html
Salesforce admin online training by 21cssindia the largest institute in providing online trainings in all technologies. Salesforce admin training, salesforce ...
salesforce developer online training| salesforce developer ...
www.21cssindia.com/.../salesforce-developer-online-training-144.html
21cssindia provides Salesforce developer online training by real time Experts. Call us +91 9000444287 for online training and demo. Online Salesforce ...
salesforce crm online training| salesforce crm training| call ...
www.21cssindia.com/courses/salesforce-crm-online-training-212.html
21cssindia provides Salesforce crm online training by real time Experts. Call us +91 9000444287 for online training and demo. Online Salesforce crm training ...

kovalan Jayamurugan said...

Thanks for sharing informative article on Salesforce technology. Your article helped me a lot to understand the career prospects in cloud computing technology. Salesforce Training in Chennai

Manish Pandey said...

Your blog is really awesome and I got some useful information from your blog. This is really useful for me. Thanks for sharing such a informative blog. Keep posting.

Regards..
Cloud Computing Training

christina jeni said...

Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.

Regards..
Software Testing Training

Andria BZ said...

Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing.
Regards,

Salesforce training in Chennai | Salesforce course in Chennai

john son said...

Salesforce is a cloud based CRM software. Today's most of the IT industry use this software for customer relationship management. To get more details about salesforce please refer this site.

Regards..

Salesforce Training Institutes in Chennai

Bay Max said...

There are lots of information about latest technology and how to get trained in them, like Hadoop Training Chennai have spread around the web, but this is a unique one according to me. The strategy you have updated here will make me to get trained in future technologies(Hadoop Training in Chennai). By the way you are running a great blog. Thanks for sharing this.

sss said...

Thanks for sharing nice information which is usefull us. Salesforce can help you get the most out of the platform.Training is required for someone to gets introduced to a new job or roll out a business change.For more details salesforce online training in hyderabad

Roshini RS said...

Thanks for sharing this useful post; Actually Salesforce crm cloud application provides special cloud computing tools for your client management problems. It’s a fresh technology in IT industries for the business management.
Regards,
Salesforce training chennai|Salesforce training institutes in Chennai

Amirtha rao said...

Thanks for sharing this valuable post to my knowledge; SAS has great scope in IT industry. It’s an application suite that can change, manage & retrieve data from the variety of origin & perform statistical analytic on it...
Regards,
sas training in Chennai|sas course in Chennai|sas training chennai|sas training institute in Chennai

Pooja Doss said...

There are lots of information about latest technology and how to get trained in them, like Best Hadoop Training In Chennai have spread around the web, but this is a unique one according to me. The strategy you have updated here will make me to get trained in future technologies Hadoop Training in Chennai By the way you are running a great blog. Thanks for sharing this blogs..

Pooja Doss said...

I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
SalesForce Training in Chennai

Pooja Doss said...

Pretty article! I found some useful information in your blog, it was awesome to read,thanks for sharing this great content to my vision, keep sharing..
Unix Training In Chennai

Pooja Doss said...

This information is impressive..I am inspired with your post writing style & how continuously you describe this topic. After reading your post,thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic
Android Training In Chennai In Chennai

Pooja Doss said...

SAP Training in Chennai
This post is really nice and informative. The explanation given is really comprehensive and informative..

Pooja Doss said...

Oracle Training in chennai
Thanks for sharing such a great information..Its really nice and informative..

Pooja Doss said...

Selenium Training in Chennai
Wonderful blog.. Thanks for sharing informative blog.. its very useful to me..

Pooja Doss said...

Data warehousing Training in Chennai
I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly..

Pooja Doss said...

Whatever we gathered information from the blogs, we should implement that in practically then only we can understand that exact thing clearly, but it’s no need to do it, because you have explained the concepts very well. It was crystal clear, keep sharing..
Websphere Training in Chennai

Pooja Doss said...

Oracle DBA Training in Chennai
Thanks for sharing this informative blog. I did Oracle DBA Certification in Greens Technology at Adyar. This is really useful for me to make a bright career..

Harshita said...

Informative article. Helped a lot as I used it to train the students in my Salesforce training institute in Chennai for. Thank you, keep writing.

Harshitha

Raju Kumar said...

thanks for sharing information,nice article
sas online training

geethu said...

I have read this content it is very nice with unique content and keep updating us.
Salesforce Training in Chennai | salesforce course in Chennai | FITA Velachery | FITA Training

geethu said...

Great content. I really enjoyed while reading this content with useful information, keep sharing.
Hadoop Training in Chennai | Hadoop Training Chennai | FITA Velachery | FITA Academy Chennai.

Savitha said...

Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
Oracle Training In Chennai

Diya Patel said...

Best SAS Training Institute In Chennai It’s too informative blog and I am getting conglomerations of info’s about Oracle interview questions and answer .Thanks for sharing, I would like to see your updates regularly so keep blogging.

Vinoth Kumar said...

PLC Training in Chennai
PLC Training Institute in Chennai
PLC Training Center in Chennai
PLC Training Course in Chennai
PLC Course in Chennai
PLC SCADA Training in Chennai
PLC Training Centre in Chennai
PLC SCADA Training Institute in Chennai
Best PLC Training in Chennai
Best PLC Training Institute in Chennai
SCADA Training in Chennai
DCS Training in Chennai
Automation Training in Chennai
Automation Training Institute in Chennai
Industrial Automation Training in Chennai
HMI Training in Chennai
VFD Training in Chennai
Process Automation Training in Chennai
Final Year Projects in Chennai
IEEE Projects in Chennai
Mechanical Projects in Chennai
Embedded Training in Chennai
VLSI Training in Chennai
Robotics Training in Chennai
Inplant Training in Chennai
AutoCad Training in Chennai
IT Training institutes in Chennai
Web Designing Training in chennai

Myouri Yash said...

Such a great post! thisis useful information blog thanks for sharing.Best safety institute in chennai|safety diploma courses training in chennai| safety courses in chennai |safety engineering courses in chennai|Best safety training institute in chennai| fire and safety courses in Chennai THIS VERY GOOD POST!

Shalini said...

Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your.
Digital Marketing Company in India

Philips Huges said...


Thanks admin for sharing the unique content, you have done a great job

Installment loans in Mississippi
Payday loans in Mississippi
Title loans in Mississippi

Petter Marry said...

I have read your blog its very attractive and impressive. I like it your blog.

Java Online Training Java EE Online Training Java EE Online Training Java 8 online training Core Java 8 online training

Java Online Training from India Java Online Training from India Java Online Training

Nannie Co Pam said...

I have read your blog its very attractive and impressive. I like it your blog.

ES6 Online Training JavaScript Training Courses JavaScript Training Courses | Angular 4 Online Training Angular 4 Online Training