I am confused how to use to getter setter in the situation of two Visualforce pages having different extensions.
1 VF Page(Main Page): This page calls Opportunity as Standard Controller and having two Extensions = Ext1, Ext2. I have a inputTextArea field where it has a lookup. On the click of the Lookup page(Second VF Page - LookupPage) user search for Employee records(custom object having SF and Non SF user list) and select multiple employees through a checkbox. On the click of the OK button in the lookup page it does gets all the Employee Names through Ext2. Till this point I am fine but I am confused how to retain the EmployeeNames from Ext2 and populate in the InputTextArea field which is on the First Page?
Page 1
<apex:page standardController="Opportunity" extensions="Ext1,Ext2" tabStyle="Opportunity" >
<apex:form id="form_Upload">
<apex:pageBlockSection title="Email Recipients" columns="2">
<apex:inputHidden value="{!allSelectedEmpIds}" id="targetId" />
<apex:pageBlockSectionItem >
<apex:outputLabel value="Email To List" for="ToList"/>
<apex:outputPanel >
<apex:inputTextarea id="empNames" value="{!empName}" onfocus="this.blur()" disabled="false"/><a href="#" onclick="openLookupPopup(); return false">Lookup</a>---This is place where I want to get the Employee Names--
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:form>
</apex:page>
Extension
public class Ext1{
public String emailToList {get;set;}
public String emailCcList {get;set;}
public String emailBccList {get;set;}
private final Opportunity opp {get;set;}
public Ext1(ApexPages.StandardController standardController) {
this.opp = (Opportunity)standardController.getRecord();
}}
public with sharing class Ext2{ public List<employeeWrapper> employeeList {get;set;}
public String allSelectedEmpIds{get;set;}
public String empName{get;set;} // This is the one I want to return to Main Page
public boolean canLookup {get;set;}
public String searchString{get;set;}
private final Opportunity opp;
public void processSelected(){
//PageReference np;
allSelectedEmpIds = '';
empName = '';
for (employeeWrapper eEmp: employeeList) {
System.debug('checkbox selected'+ eEmp.isSelected);
if(eEmp.isSelected){
allSelectedEmpIds += ';'+eEmp.employee.Id;
empName += ';'+eEmp.employee.FullName__c;
}/*else{
allSelectedEmpIds += ';'+eEmp.employee.Id;
} */
}
}
Page 2
<apex:page id="employeeLookupPage" controller="Ext2" showHeader="false">
<apex:form >
<apex:pageBlock title="Employee List" id="employeblock">
<apex:pageBlockSection id="Section" showheader="false" columns="1">
<!--apex:pageblocksectionitem id="SectionItem" >
<apex:outputLabel value="First Name or Last Name Search" for="searchStringPanel" style="font-weight:Bold;padding-right:10px;" />
<apex:outputPanel id="searchStringPanel"-->
<apex:inputText id="srchString" value="{!searchString}"/>
<apex:commandButton title="Go!" value="Go!" reRender="employeePanel" action="{!search}"/>
<!--/apex:outputPanel>
</apex:pageblocksectionitem-->
</apex:pageBlockSection>
<apex:outputPanel id="employeePanel">
<apex:pageBlock id="employeeBlock">
<apex:inputHidden value="{!allSelectedEmpIds}" id="targetId" />
<apex:inputHidden value="{!empName}" id="namefield" />
<apex:pageBlockTable value="{!employeeList}" var="empNames">
<apex:column >
<apex:inputCheckbox value="{!e.isSelected}" id="selectedEmp"/>
</apex:column>
<apex:column id="fname" >
<apex:facet name="header">First Name</apex:facet>
<apex:outputText value="{!e.employee.First_Name__c}"/>
</apex:column>
<apex:column headerValue="Last Name">
<apex:outputText value="{!e.employee.Last_Name__c}"/>
</apex:column>
<apex:column headerValue="Email">
<apex:outputText value="{!e.employee.Email__c}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:outputPanel>
<apex:pageBlockButtons location="bottom">
<div align="Right" draggable="false">
<apex:commandButton value="Ok" action="{!processSelected}" />
<apex:commandButton value="Cancel" onclick="window.top.close()" />
</div>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:page>