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
sornasorna 

Use one visualforce page as an iframe in another visualforce page

Hi,

I have a requirement where I have to display one VF page as an iframe in another VF page. Both the VF pages are sharing the same controller. From first VF page, on a click event I will query some records in the controller and those records should be displayed in the iframe which is the second VF page. So, in the iframe, how can I refer the page? If I refer like {!$page.secondPage}, the controller class variables used in this VF is coming as null. Can anyone tell me how should I refer the second page in the iframe with maintaining the controller class variables?

 

 

 

Thanks,

sorna

Abhinav GuptaAbhinav Gupta

Though both the iframe page and parent page will share the same controller, still its not possible for them to share the state i.e. query records from one page and make them available to other. This is because VF maintains a view state per page. 

Ronen.ax767Ronen.ax767

Hi,

 

Send the variables on the ifame URL

 

example: (write in VF page)

 

      <ifram src=".../MyVFPage?var1= { ! MyVariable1 } &&var2= {  ! MyVariable2 } " .../>

 

And read the variables in the ifram controller

 

        PageReference pageRef = ApexPages.currentPage();
        Map <String,String>pageMap = pageRef.getParameters();
        String var1 = pageMap.get('var1')

 

hope this helps.

 

 

guest1231231guest1231231

Have you tried this?

 

 

<apex:include pageName="MyVisualForcePageName"/>

 

 

sornasorna

Hi All, 

thanks for your replies. Finally I chose the way which Ronen said and it is working fine now.

 

 

Thanks once again

Sorna

vivekanandanvivekanandan

Hi,

 

can you please send me the code snippet which worked ofr you. Becasue I have the same requirement of iframe inside a vf page.

 

Thanks in Advance

vivek