You need to sign in to do that
Don't have an account?
Passing data from one Visualforce page to other in the using same controller.
Hi,
I have below requirement.
I have displayed list with checkboxes on one Visualforce page.
Selecting some records, i have to click the "Accept" button which will open new visualforce page in new window on top of existing window.
On this page, user will select value from picklist, and will update all the selected records from the parent page with this selected picklist value.
Now, I have to use same controller for both the pages as data should be available there which is selected from the two pages(checkboxex from one page and picklist value from new window visualforce page).
If i select picklist value , as it is new page , its controller(Constructor) will be called again which will erase my previosly selected records from first VF.
Please suggest solution for this.
Thanks in advance.
Instead of using two VF pages,why cant you use two outputpanels containing the
two VF pages.You rerender output panel #1 and and output panel#2 according to your wish.
In this method you can use the same Controller.
hi,
If you are using same controller for different pages, then there state should be maintained. Make sure, Page.setRedirect is false on button click.
if still problem persists, please post your code.
Hi Rohit,
Thanks for the reply, but my scenario is bit different.
Please find below the details about code and process flow:
Main VF page:
<script>
function selectCloseDate(){
window.open('/apex/LA_CloseDatePage','','height=300,width=700',replace=false);
}
</script>
<apex:pageBlocktitle="title">
<apex:pageBlockButtons location="top" id="pageBlock_Buttons">
<apex:commandButtonid="accept"value="Accept"action="{!acceptProcess}"reRender="faSpcTable"
onClick="selectCloseDate();"/>
</apex:pageBlockButtons>
<apex:pageBlockTablevalue="{!clientlistDetail}"var="s"width="100%"id="fa_pageBlockTable">
<apex:columnid="col_umn">
<inputname="nx"type="checkbox"value="{!s.selected}"id="checkedone">
<apex:actionSupportevent="onclick"action="{!GetclientlistDetailSelectedId}"rerender="pqr"/>
</input>
</apex:column>
<apex:columnheadervalue="Status"value="{!s.status}"/>
</apex:pageBlockTable>
second VF code:
<apex:page standardController="Employee_Shadow__c" extensions="AL_CwlaFASpecialistListDetailController" sidebar="false" showHeader="false">
<script>
function closeWindow(){
alert('closing window...');
window.close();
}
</script>
<apex:form >
<apex:pageBlock title="My Content" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!updateOpportunities}" value="Save Records" onclick="return closeWindow();" immediate="true"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Select close date" columns="2">
<apex:inputField value="{!Employee_Shadow__c.WKR_BRTH_DT__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Here in above code, i am using same extension controller for both the VFs.
I want to open VF page in new window, on click of button of existing page.
Before clicking the button, i am selecting some checkboxes, so want to retain those checkboxes values as it is when new window is opened.
In new window , i am selecting date value from VF page, and clicking on "Save recs" button.
On clicking this button on new window, i want to save all selected records from previous page(parent page) with the updated value in picklist which i selected in new window.
Please help.
Anyone,please, if have came across the same scenario or like...
Thanks.
post your extention code also
Please find below the extension controller s code:
Action method to be called from first page:
public
PageReference clientListDetailSelectedRecordIds(){
String idString =
'';
clientListDetailSelectedId.clear();
system.debug('PKP');
for(CwlaListbreakdownwrapper clientwrapper : clientListDetail){
if(clientwrapper.selected == true){
//clientListDetailSelectedId.add(clientwrapper.listDetailId);
Id ilistDetailId= clientwrapper.listDetailId;
idString=idString+
';'+ilistDetailId;
}
}
integer stringLength = idString.length();
if(idString.endsWith(';')){
idString = idString.subString(0,stringLength);
}
sListDetailIdString = idString;
system.debug('ARUNA 1: String of ids: '+sListDetailIdString);
returnnull;
}
Action method called from page in new window:
public
Pagereference updateOpportunities(){
System.debug(
'#### close date: '+Employee_Shadow__c.WKR_BRTH_DT__c);
System.debug(
'#### Selected ids: '+clientListDetailSelectedId);
System.debug(
'#### clientListDetail.size(): '+clientListDetail.size());
for(CwlaListbreakdownwrapper clientwrapper : clientListDetail){
if(clientwrapper.selected == true){
System.debug(
'#### listDetailId: '+clientwrapper.listDetailId);
}
}
returnnull;
}
These are just debug staements i tried to check if i am getting the data.
But as new page in new window is opened and that refers to the same controller as of Parent, constructor is called again and previous data is deleted.
Please suggest.
Hi Rohit,
I have put the simple code at another link.
Probably it will help betterunderstanding the exact problem.
http://boards.developerforce.com/t5/forums/postsuccesspage/board-id/Visualforce/message-id/40011
Thanks,
Aruna