You need to sign in to do that
Don't have an account?
Gabe Rothman 8
Banging my head against a wall -- visualforce page pass picklist value into apex:iframe src parameter
Hey folks, I know I'm gonna feel stupid when I get the answer here, but I just can't seem to get this right. I'm trying to create a visualforce page that populates other visualforce pages within an iframe based on a picklist selection, btu I can't seem to figure out how to pass the selected picklist value into the src parameter of my iframe component. I've deleted a bunch of the broken code that hasn't worked so the code is pretty simple at this point.
Can someone help me sort it out? Thanks!
Controller:
VF Page:
Can someone help me sort it out? Thanks!
Controller:
public class domoDashboardController { public List<String> pagename { get { if (pagename == null) { pagename = new List<String>(); list<ApexPage> pages = [SELECT Name FROM ApexPage WHERE Name != 'domoDashBoardViewer' AND Name LIKE 'DOMO_%' ORDER BY Name ASC]; for (ApexPage page : pages){ pagename.add(page.Name); } } return pagename; } set; } }
VF Page:
<apex:page controller="domoDashboardController"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <apex:pageBlock title="DOMO Dashboard Viewer" mode="edit"> <apex:form> <table width="100%" border="0"> <tr> <td style="font-weight:bold; padding-left: 5px; padding-top:10px; width: 125px;"> Select Dashboard: </td> <td style="font-weight:bold; padding-top:8px;"> <select id="pagename"> <option value=""></option> <apex:repeat value="{!pagename}" var="pag"> <option value="{!pag}">{!pag}</option> </apex:repeat> </select> </td> </tr> </table> <apex:pageBlock> <table width="100%" border="0"> <tr> <apex:page id="thePage"> <apex:iframe src="" scrolling="true" id="theIframe"/> </apex:page> </tr> </table> </apex:pageBlock> </Apex:form> </apex:pageBlock> </apex:page>
All Answers
Re-render the iFrame block, each time select option is changed.
Modify it as : <apex:iframe src="{!iframeURL}" scrolling="true" id="theIframe"/>
Just for your reference, I made two adjustments.
I changed the "return pagename" in the code below to "return pageNameList"
01public List<SelectOption> pageNameList {
02 get {
03 if (pageNameList == null) {
04 pageNameList = new List<SelectOption>();
05 list<ApexPage> pages = [SELECT Name FROM ApexPage WHERE Name !='domoDashBoardViewer' AND Name LIKE 'DOMO_%' ORDER BY Name ASC];
06 for (ApexPage page : pages){
07 pageNameList .add(new SelectOption(page.Name,page.Name);
08 }
09 }
10 return pagename;
11 }
12 set;
13 }
I also changed
1public void setIframeUrl(){
2 if(pageName != null){
3 iframeURL = '/'+ pageName ;
4 pageName = null;
5 }
6}
to
1public void setIframeUrl(){
2 if(pageName != null){
3 iframeURL = pageName ;
4 pageName = null;
5 }
6}
I didn't need the ' / ' + portion of the code because I'm not referencing a URL, I'm actually just referencing the name of the iframed VF page directly.
Anyway, thanks again for your help. I really appreciate it!