0

I have a requirement of passing the Id of the parent page to the pop-up form, so that when a user clicks the 'CANCEL' button on the pop-up the control gets transferred back to the parent page.

For this, I need to have the Id of the original page in context. This page has a custom button which when clicked opens up a pop-up.

Any help is appreciated.

Here is the code that opens up a pop-up...

{!REQUIRESCRIPT('/soap/ajax/26.0/connection.js')} 
{!REQUIRESCRIPT('/js/functions.js')} 
{!REQUIRESCRIPT('/resource/jQueryForPopup/jQuery/jquery-1.8.2.min.js')} 
{!REQUIRESCRIPT('/resource/jQueryForPopup/jQuery/ui/jquery-ui-1.9.1.custom.min.js')} 
{!REQUIRESCRIPT('/resource/jQueryForPopup/jQuery/postmessage/jquery.ba-postmessage.js')} 
{!REQUIRESCRIPT('/resource/jQueryForPopup/jQuery/bbq/jquery.ba-bbq.min.js')} 
requireCssFile('/resource/jQueryForPopup/jQuery/ui/css/ui-lightness/jquery-ui-1.9.1.custom.min.css'); 


function requireCssFile(filename) 
{ 
var fileref = document.createElement('link'); 
fileref.setAttribute('rel', 'stylesheet'); 
fileref.setAttribute('type', 'text/css'); 
fileref.setAttribute('href', filename); 
document.getElementsByTagName('head')[0].appendChild(fileref); 
} 


var j$ = jQuery.noConflict(); 
var iframe_url = '{!URLFOR("/apex/Add_address")}'; 

var j$modalDialog = j$('<div id="opppopup"></div>') 
.html('<iframe id="iframeContentId" src="' + iframe_url + '" frameborder="0" height="100%" width="100%" marginheight="0" marginwidth="0" scrolling="no" />') 
.dialog({ 
autoOpen: false, 
title: 'Add Details', 
resizable: true, 
width: 800, 
height: 540, 
autoResize: true, 
modal: true, 
draggable: true 
}); 

j$modalDialog.dialog('open');

Here is the VF page:

    <apex:outputPanel id="tstpopup">

         <apex:pageBlockSection >
         <apex:pageblockSectionItem >
            <apex:outputlabel for="Address_Line1">
            Address Line 1
            </apex:outputlabel>
            <apex:panelGroup >

            <apex:inputtext id="Address_Line1" value="{!AddrLine1}" required="true"/>


                            <apex:pageBlockSection >
         <apex:pageblockSectionItem >
            <apex:outputlabel for="Country">
            Country
            </apex:outputlabel>
            <apex:panelGroup >

            <apex:inputText id="Country" value="{!Country}" required="true"/>

            </apex:panelGroup>
            </apex:pageblockSectionItem>
            </apex:pageBlockSection>


            <apex:commandButton value="Cancel" action="{!closePopup}" onclick="window.close();">

            </apex:commandButton>
            <apex:commandButton value="Save" action="{!save}" rerender="abcd">

            </apex:commandButton>

  </apex:outputPanel>

The user after entering Address Line 1 and the country fields can either click CANCEL or SAVE buttons.

6
  • Are you talking about the html id? – highfive Jul 16 '14 at 9:28
  • I am talking about the default salesforce Ids – juhi Jul 16 '14 at 9:32
  • Is your popup also another visualforce page? – highfive Jul 16 '14 at 9:37
  • the pop-up is a javascript that calls a visualforce page – juhi Jul 16 '14 at 9:42
  • So at the place where you call the popup link, add the id as a query string and use it in the popup. Can you edit the question and add the code where you call the popup – highfive Jul 16 '14 at 9:43
1

You can pass values by using the query string.

var iframe_url = '{!URLFOR(/apex/Add_address?parent_id=your_parent_page_id)}'; 

And then in the popup page controller constructor, grab the id like below

String ppId = System.currentPageReference().getParameters().get('parent_id');
7
  • I tried this..But because the pop-up opens on the same page so the redirecting to the parent page does not happen – juhi Jul 16 '14 at 12:04
  • What you mean by redirecting here?if it's a popup, just closing the popup(may be upon clicking cancel as you have mentioned) user will automatically land into the parent page right?btw,this answer is for your question "how to pass is to popup page" – highfive Jul 16 '14 at 13:30
  • When the user clicks on 'Cancel' nothing is happening as of now. :( i want to redirect to the page on which the button was originally clicked to open the popup. – juhi Jul 16 '14 at 13:34
  • if you need to close the popup and let user land into the parent page, add top.close(); into the onclick event of your cancel button. No need to purposely redirect. – highfive Jul 16 '14 at 14:28
  • top.close() isn't working... – juhi Jul 16 '14 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.