You need to sign in to do that
Don't have an account?
Gstart
Question in passing data between two visualforce pages using the same controller?
I am new to development and trying to figure out the best way to pass data between pages. I have done the following right now
i) Created 2 custom objects
ii) Created 2 visualforce pages using one object each
iii) One controller class for both the pages
I get the input for 1st object in the first page and then pass them to the second page where I get the input for the 2nd object and then save both together in the second page.(No save happens in first page)
I created one custom class for both the pages but I have mentioned it as the extension class in the visualforce page.
When I navigate from Page1 to Page2, how do I pass all the data entered in the first page. I tried using ApexPages.StandardController in the constructor and then using sc.getRecord() but it throws an error because the object differs between pages. It works only when I use same object in both pages.
i) Created 2 custom objects
ii) Created 2 visualforce pages using one object each
iii) One controller class for both the pages
I get the input for 1st object in the first page and then pass them to the second page where I get the input for the 2nd object and then save both together in the second page.(No save happens in first page)
I created one custom class for both the pages but I have mentioned it as the extension class in the visualforce page.
When I navigate from Page1 to Page2, how do I pass all the data entered in the first page. I tried using ApexPages.StandardController in the constructor and then using sc.getRecord() but it throws an error because the object differs between pages. It works only when I use same object in both pages.
It's like this:
Let's say I am entering Account, Contact and Opportunity from same UI then I need to provide all required field of Account first, then all required field of contact and then all required fields for Opportunity.
And when it's time to save the record, I would have controller behind the save button like below,
But at the same time, I would also make sure that as user enters Account field into visualforce page and then moves on to Contact then All Account field values has been stored and not lost.
Hope this helps!
Class: This works well if both of my visualforce use the same object object1__c. But my second page uses object2__C as the standard controller but this class is defined as the extension. How do I need to convert this so that I get all object1__C data in the second page. I have shared the visualforce header implementation below.
Page1:
Page 2:
I navigage from page 1 to page 2 using the movetoStep2 method. But, after arriving to page 2, I need to get the values I entered for object1 in Page1. How do I achieve this?