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
aruna11.3081223889641084E12aruna11.3081223889641084E12 

Setting input field value in from Two visualforce pages in same controller

Hi,

 

I am facing the problem in below scenario:

 

I have created 1 visualforce page, which used extension controller.

I want to input some values in the page and on clicking button, new window should be opened as a popup which in which i will put some more data and will ckick on save button in popup window page.

Both the pages will use same extension controller.

But the problem is, if i enter the data on new window page, and click save, that inputfield is giving me null value.

 

Please find below my simple code:

Page 1:

AccountPage:

 

<apex:page standardController="Account" extensions="AccountExtController">
    <apex:form >
        <apex:pageblock title="Date Section">
            <apex:pageBlockButtons >                                
                <apex:commandLink action="{!doAction}" value="SaveLink" id="theLink" target="_new">   
                    <apex:param name="accId" value="{!account.Id}"/>
                </apex:commandLink>               
            </apex:pageBlockButtons>
            <apex:inputField value="{!account.OppCloseDate__c}"/>
            </apex:pageblock>
    </apex:form>
</apex:page>

 

Second page: NewWindowPage

 

<apex:page standardController="Account" extensions="AccountExtController" sidebar="false" showHeader="false">
<script>
function closeWindow(){
    alert('closing window...');
    //window.close();       
}
</script>

<apex:form >
    <apex:pageBlock title="My Content">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!updateAccountAndCreateOpp}" value="Save Records" onclick="return closeWindow();" immediate="true"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Select NBK ID" columns="2">
                <apex:inputField value="{!account.NBKID__c}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
</apex:form>
</apex:page>

 

Extension controller:

 

public class AccountExtController {
    Account acc{get; set;}
    String accCloseDate='';
    public AccountExtController(ApexPages.StandardController controller) {
        System.debug('inside constructor...');
        acc = (Account)controller.getRecord();
    }
   
    public Pagereference doAction(){
        System.debug('inside doAction...');
        String aid = Apexpages.CurrentPage().getParameters().get('accId');
        System.debug('aid: '+aid);

        System.debug('account opp close date: '+acc.OppCloseDate__c);
        accCloseDate = ''+acc.OppCloseDate__c;
        

        Pagereference ref = Page.NewWindowPage;  
        ref.getParameters().put('id',acc.Id);
        ref.setRedirect(false);
        return ref;   
    }

 

    public Pagereference updateAccountAndCreateOpp(){
        Id secondpageId = ApexPages.currentPage().getParameters().get('id');
        System.debug('#### accCloseDate: '+accCloseDate);    

        System.debug('#### acc: '+acc);
        System.debug('#### acc.NBKID__c: '+acc.NBKID__c);
        return null;
    }
}

 

 

The above method "updateAccountAndCreateOpp" is called from second VF page in which i have set debug statements.I n this method, i am able to retain first page data as i have set redirect to false, for second page.

But i am not able to get the data in inputfield on second page.Its coming null.

 

Please suggest how to associate data on second page?

 

Thanks in advance.


 

bob_buzzardbob_buzzard

This sounds like you are hoping to use the same controller instance across the two pages - is that correct?

 

If so, that won't work, as these pages are separate from both the browser and the Salesforce perspective.  You have a couple of options I'd say:

 

(1) Have the popup pass the information entered back to a hidden input field on the main page

(2) Use layers rather than a separate window - that way it will be the same controller.

SoozeeSoozee

Hello,

I just came across this post because I am running into the same issue.

Can you give me more information or examples of how to pass info from pop up back to hidden field on main page?

 

Thanks!