You need to sign in to do that
Don't have an account?
Vivek Viswanath
Passing data between pages using controllers
Hi
I was trying to pass data between pages using the controller which failed. Is this possible every time I redirect I loose the state of the controller.
I have two pages with the same controller can I keep the data in the controller when I move from one page to the other sharing the data betweent he pages.
Regards
Vivek
Message Edited by Vivek Viswanath on 07-22-2008 10:50 AM
Message Edited by Vivek Viswanath on 07-22-2008 10:51 AM
I was trying to pass data between pages using the controller which failed. Is this possible every time I redirect I loose the state of the controller.
I have two pages with the same controller can I keep the data in the controller when I move from one page to the other sharing the data betweent he pages.
Regards
Vivek
Message Edited by Vivek Viswanath on 07-22-2008 10:50 AM
Message Edited by Vivek Viswanath on 07-22-2008 10:51 AM
http://www.salesforce.com/us/developer/docs/pages/Content/pages_quick_start_wizard.htm
here is a snippet
Message Edited by Ron Hess on 07-22-2008 11:03 AM
Message Edited by Ron Hess on 07-22-2008 11:05 AM
I was using that as my example however was having trouble when I was putting an action on the apex page
here is the code:
public PageReference init()
{
setOpportunityId(); // sets the id from the url only if its null or empty
return registrationKitReOrder();
}
public PageReference registrationKitReOrder()
{
return Page.TestPage;
}
<apexage controller="SFDCRegKitController" action="{!init}" >
</apexage>
This is my page I put in debug statements and it goes into that part of the code and also returns the page. However its not displayed. Please let me know what I am doing wrong here
I got a post saying this is a known issue and hence I change it as suggest to the following
public PageReference registrationKitReOrder()
{
PageReference reorder = Page.TestPage;
reorder.setRedirect(true);
return reorder;
}
which works in directing it to the second page however fails to carry the data over
Message Edited by Vivek Viswanath on 07-22-2008 11:35 AM
Try this:
you can do a setRedirect() then after that i think you can add a parameter to the page, then return the page
public PageReference registrationKitReOrder()
{
PageReference reorder = Page.TestPage;
reorder.setRedirect(true);
reorder.getParameters().put('id', getOpportunityId() );
return reorder;
}
I am using that though i can pass the opportunity Id there is a lot more data than just the opp id, I was concerned about re-quering for data and was hoping for another workaround :D.
Regards
Vivek
Message Edited by Vivek Viswanath on 07-22-2008 11:46 AM
I am facing the same issue...Here is the code
PAGE - FirstPage
<apex:page standardController="Design__c" extensions="DesignController" action="{!init}">
<!-- SOME TEXT DISPLAYED -->
<apex:outputpanel>
<apex:commandButton action="{!openSecondPage}" value="Open Second Page"/>
</apex:outputpanel>
</apex:page>
CLASS
global class DesignController {
public DesignController(ApexPages.StandardController controller){
parentId = controller.getRecord().Id;
}
public PageReference init(){
application = new MetadataWrapper.Application();
....
//PERFORM SOME ACTION TO POPULATE application object
...
return null;
}
public PageReference openSecondPage(){
return Page.SecondPage;
}
public Class Wrapper {
public String name {get; set;}
public String typr {get; set;}
public Boolean isSelected {get; set;}
public Wrapper(String name, String type, Boolean isSelected){
this.name = name;
this.type = type;
this.isSelected = isSelected;
}
}
}
In this case if I dont set setRedirect to true, on the click of the button, the page (FirstPage) reloads again thereby invoking the action function (init) and the second page (SecondPage) does not load.
However, if i do set setRedirect to true, the SecondPage loads but the data (application object) is not passed through.
Any thoughts on how this behaviour can be rectified?