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
MellowRenMellowRen 

Refresh parent page components from included page, how?

Hi

 

I have a problem in getting communication between an included page and its parent page. Here is a very simplified version of two of my pages.

 

Main Page
-------------
<apex:page controller="MainPageCntr" extensions="SubPageC">
   <!-- The page -->
   <apex:outputPanel id="displayArea"> <!-- Used to rerender whole page -->
      <!-- Main Display -->
      <apex:outputPanel id="OppArea" rendered="{!switchOn}">
         <apex:form>
            <apex:commandButton action="{!switchView}" value="Do it" rerender="displayArea"/>
         </apex:form>
         <apex:include pageName="SubPage" />  <!-- The Controller of this page is SubPageC -->
         <apex:include pageName="AnotherPage" />
      </apex:outputPanel>

      <!-- Secondary Display -->
      <apex:outputPanel id="OppArea" rendered="{!switchOff}">
         <apex:form>
            <apex:commandButton action="{!switchView}" value="Go Back" rerender="displayArea"/>
         </apex:form>
         A heap of other stuff goes here.
      </apex:outputPanel>
   </apex:outputPanel>
</apex:page>

Sub Page
-------------
<apex:page controller=" SubPageC " >
   <!-- The page -->
   A whole heap of stuff but here is where I need a second clickable control.
         <!-- eg  <apex:commandButton action="{!switchView}" value="Do it" rerender="displayArea"/>  -->
</apex:page>

 

The CommandButton on the main page hides one area, including the included pages, and displays a secondary one (until a user clicks a return button). The main page, the sub-pages and this button all work fine (in reality displaying a complex set of charts and tables relating to the business).

 

The problem? I now have a requirement of putting a similar button into the subpage itself. It needs to pass data and switch the views. I can’t figure out how to rerender displayArea from the subpage. Simply using the rerender attribute doesn’t work. I have tried using JavaScript in the subpage to reload the whole page. I also put this in the main page and had JavaScript in the subpage try and call it.  I seem to get into a weird refresh / reload infinite loop.

 

    <!-- The JS function for sub-page -->
    <apex:form>
        <apex:actionFunction name="refreshTheDA" rerender="displayArea"/>
    </apex:form>

 

Does anyone know how to do this?

 

Or any ideas on what to try?

 

Regards

MellowRen

Arun MKArun MK

Hi,

 

Try not to give reRender for the switchView action.