0

I have create a scenario. I have create 2 VF Page. PageOne is Main page which contain same information and PageTwo is a lookup popup page which are hold some picklist or other things.

Apex controller are same for both page.

My Question is when i click the Done button (lookup page PageTwo) the selected picklist item show into the main page(PageOne) inputTextarea.

please help me out.

//---------------VF PageOne -------------------------

function openLookupPopup(){ var win = window.open("/apex/PageTwo", "Lookup", "height=500,width=1050"); }
<apex:form id="IdFrm">
    <apex:pageBlock id="IdPBEdit">
        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!saveMethod}"/>
            <apex:commandButton value="Cancel"/>
        </apex:pageBlockButtons>
        <apex:pageBlockSection title="Select Details">
            <apex:pageBlockSectionItem >
                <apex:outputLabel >Select Records</apex:outputLabel>
                <apex:outputPanel >
                    <a href="#" id="IdLookup" onclick="openLookupPopup();" tabindex="2" title="Assigned To Lookup (New Window)" style="text-decoration: none;" oncomplete="setTask();">
                        <img src="/s.gif" alt="Assigned To Lookup (New Window)" class="lookupIcon" onblur="this.className = 'lookupIcon';" onfocus="this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';" onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" title="Assigned To Lookup (New Window)"/>
                    </a>
                </apex:outputPanel>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
        <apex:pageBlockSection title="Details">
            <apex:pageBlockSectionItem >
                <apex:outputLabel >List One</apex:outputLabel>
                <apex:inputTextarea value="{!ListOne}"/>
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem >
                <apex:outputLabel >List Two</apex:outputLabel>
                <apex:inputTextarea value="{!ListTwo}"/>
            </apex:pageBlockSectionItem>                                
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>

//----------------apex Controller ----------------------------- public class VFTestController {

public String ListTwo { get; set; }
public String ListOne { get; set; }   
public List<String> oneList {get;set;}
public List<String> twoList {get;set;}


public VFTestController(){   
    oneList = new List<String>();
    twoList = new List<String>();
}

public List<SelectOption> getOneListOption() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('List One Item - 1','List One Item - 1'));
    options.add(new SelectOption('List One Item - 2','List One Item - 2'));
    options.add(new SelectOption('List One Item - 3','List One Item - 3'));
    options.add(new SelectOption('List One Item - 4','List One Item - 4'));
    return options;
}
public List<SelectOption> getTwoListOption() {
    List<SelectOption> options = new List<SelectOption>();
    options.add(new SelectOption('List Two Item - 1','List Two Item - 1'));
    options.add(new SelectOption('List Two Item - 2','List Two Item - 2'));
    options.add(new SelectOption('List Two Item - 3','List Two Item - 3'));
    options.add(new SelectOption('List Two Item - 4','List Two Item - 4'));
    return options;
}
public PageReference saveMethod(){            
    return null;
}

public PageReference done() {
    ListOne = oneList[0] ;
    ListTwo = twoList[0];
    return null;
}

} //---------------------------VF Lookup page PageTwo--------------------- Item One Item One

0

Create a function in your page something like:

function reloadAndClose(){
    setTimeout(function(){window.opener.location.reload(true);}, 2000);
    setTimeout(function(){window.close();}, 2100);
}

parameter (true) you send to reload method means:
true - Reloads the current page from the server.
You need to define this parameter because default is false.

Then call this function onComplete of your action which is on the second page.

  • Hi @umithuckan, Thanks for your replay :) i have try this scenario but it's not working proper. i think i am going to wrong track. Could you please show in proper format or example. – GmDeepakChounan21 Nov 16 '16 at 13:19

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.