function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SalesRedSalesRed 

Rerender Visualforce Parent Component Panels from another component

Hello,

 

I have a visualforce page with a form I have created as a component.  Within the form component I have included a reference to another component which holds the commandButton.  There are 3 output panels within my form.  Within my component for the commandButton I have entered reRender="myStatus,FormFields,FormActions" . When I click on the button the page just refreshes with all panels redisplayed but this is incorrect as the form should have rerendered with different fields.

If I don't use a component for the commandButton and instead use the code for the commandButton in the form component the panels rerender ok.   is it possible that one component cannot rerender panels in a parent component?

 

Any help on this would be appreciated.   I tried to use a container panel as suggested in the following blog but this did not seem to work either.  http://bobbuzzard.blogspot.co.uk/2011/02/visualforce-re-rendering-woes.html

 

Maybe what I'm trying is not possible?

 

Thanks in advance!

tggagnetggagne

It should be possible, or at least, it sounds like something we do ourselves.

 

In our case, our components accept an attribute named rerenderList.  We pass the list of panels we want rerendered by the component.

 

So inside the component we'll have something similar to:

 

<apex:attribute name="rerenderList" description="a csv list of elements to be rerendered" type="String" required="true"/>

 Then further down inside the component, we'll rerender the items in the list:

 

<apex:commandButton value="Save" action="{!controller.update}" rerender="{!rerenderList}" />

The component is invoked using something similar to:

 

<c:component rerenderList="id1,id2,id3" />

 

 

 

SalesRedSalesRed

Hi tggagne,

 

Thanks for your suggestion.  I tried this out but it did not work unfortunately.  it still just rerenders what's in the immediate component and no panels sitting in the apex page outside of the component.

 

Thanks for the suggestion though.  Unfortunately still trying to resolve it at present.

 


rklaassenrklaassen

Does your action (pagereference) gets fired? If not, the component doesn't know your action. Do you have a controller attribute in you component? Or an attribute tag containing the controller? If not, you have to add this to make it work.

Normally, when the page doesn't recognize the id tags, it just refreshes nothing. 

 

Besides that, it's better to refer to your id tags the following way: reRender="{!$Component.myStatus},{!$Component.FormFields},{!$Component.FormActions}". You can read more about that here: 

http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_best_practices_accessing_id.htm?SearchType=Stem

 

Good luck!

dleonp@adcapital.cldleonp@adcapital.cl

Hi, 

 

I think I have a similar problem you had... I have two components, but I need if I have changes in one, the other one is rendered again.

 

Could you resolve this issue?

 

Thank you in advance...

DetteDette
Hi,
I just faced the same problem and after some hours of searching i found a solution, i wanted to share with you:
Component: 

<apex:component id="theComponent">
<apex:attribute name="rerender" description="Hand over a list of additional element ids to rerender" type="String" required="false"/>
<apex:outputPanel id="theOutputPanel">
   ...
</apex:outputPanel>
<apex:actionFunction name="refresh"  action="{!refresh}" reRender="{!$Component.theComponent.theOutputPanel},{!rerender}" id="ActionFunction"/>
</apex:component>

And in the parent page:
<apex:page controller="PositionChartController" id="thePage" tabStyle="MediaCampaign__c">
  <apex:form id="theForm">
  <c:MyComponent rerender="thePage:theForm" id="myComponent"/>


As rklaassen wrote, it is recommended to use the $Component notation for refering to Ids. But in this case it did not work with rerender="{!$Component.thePage.theForm}".  Using the pure form rerender="thePage:theForm" works.
phani joshiphani joshi
Hello Dette, Can you please share 
action="{!refresh}" method which you used above ?