7

I have a component within an outputPanel like this:

    <apex:panelGrid columns="5" id="theDataGrid">
          <c:GraphAndTable whichData="leadByRep" description="Description 1"/>
    <apex:panelGrid>

I have this action function that triggers the rerender (I checked it works fine)

    <apex:actionFunction name="selectDateRange" rerender="theDataGrid" >
            <apex:param name="dateParam" assignTo="{!mSelectedDateFilter}" value="" />
    </apex:actionFunction>     

Problem: although the panelGrid is reRendered the component inside does not. Is there anyway to cause the component to reRender as well?

1
  • Has anyone solved this conundrum? I'm stuck with two components that contain buttons and output panels, but they won't rerender apex:outputPanel components, even though they're inside the same apex:component definition.
    – Isaac
    Commented Jul 23, 2016 at 6:07

4 Answers 4

4

I'm surprised this doesn't work but then I can't remember if I've ever tried it.

Given the global nature of javascript variables and elements used in components you could put an <apex:outputPanel> inside your component wrapping everything else, and give it a particular ID.

Then specify that ID in the rerender attribute of the <apex:actionFunction> as well.

2
  • 1
    This didn't work either, I'm now looking into other possible causes for my component table not showing the right data. Originally I thought it is because of the rerender but I'm starting to look at other directions. Will update
    – Dedo
    Commented Mar 6, 2013 at 7:54
  • Does that mean it is re-rendering? I'd use a very simple boolean variable or something to check that.
    – Matt Lacey
    Commented Mar 6, 2013 at 22:39
4

I would've expected it to rerender. The Order of Execution for Visualforce Page Postback Requests would lead me to believe that the component's controller set methods should be called and the view state should be updated. This seems similar to the recently asked question on apex:details not rerendering.

You could reRender the component on the onComplete of the actionFunction, similar to a workaround for the apex:details issue.

<apex:panelGrid columns="5" id="theDataGrid">
    <apex:outputPanel id="componentContainer">
      <c:GraphAndTable whichData="leadByRep" description="Description 1"/>
    </apex:outputPanel>
<apex:panelGrid>


<apex:actionFunction 
    name="selectDateRange" 
    rerender="theDataGrid" 
    oncomplete="updateComponent();">
        <apex:param name="dateParam" assignTo="{!mSelectedDateFilter}" value="" />
</apex:actionFunction>

<apex:actionFunction name="updateComponent" reRender="componentContainer"/>
0
1

It would appear you're not the only one who has come across this issue.

...The solution is to nest the conditionally rendered output panel inside another output panel and change the command button to rerender that. The containing output panel will always be present on the page and thus the Ajax request will be able to update it on completion. The inner component may or may not be rendered depending on the value...

I grabbed the preceeding snippet from this blog post: http://bobbuzzard.blogspot.com/2011/02/visualforce-re-rendering-woes.html

2
  • 2
    This solution solved a different problem, that of re-rendering a conditionally rendered element. The issue being that if an element is not rendered then it's not in the markup and hence can't be used for a rerender. The question is asking specifically about rerendering <apex:component>.
    – Matt Lacey
    Commented Mar 5, 2013 at 22:13
  • Thanks Jonny, this link actually solved a different problem I was having and didn't get around to investigate.
    – Dedo
    Commented Mar 6, 2013 at 7:49
0

For anyone who comes across this, the solution for me was to create an outputPanel around the component and rerender that instead of the component itself.

You must log in to answer this question.

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