You need to sign in to do that
Don't have an account?
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
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.
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.
Have you tried this?
Hi All,
thanks for your replies. Finally I chose the way which Ronen said and it is working fine now.
Thanks once again
Sorna
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