You need to sign in to do that
Don't have an account?
Shruthi GM 4
I need to pass all the filled details from vf page 1 to another vf page.How do I do that?..Here is the code.
Controller:-
public with sharing class Project1 {
public Project1() {
}
//Declaration
private ApexPages.StandardController controller;
public Project__c proj{get;set;}
public String projectId{get;set;}
public Id currentProjectId{get; set;}
public Project__c ProjectRec{get;set;}
public boolean isRendered{get;set;}
public boolean isNew_s{get;set;}
//Constructor
public Project1(ApexPages.StandardController stdController) {
projectId = ApexPages.currentPage().getParameters().get('Id');
if(projectId != null)
{
this.ProjectRec= [ SELECT Name,
Description__c,
Area_of_focus__c,
Expected_Output_Outcomes__c,
Achievements__c,
Country__c,
Budget__c,
Project_s_Start_date__c,
Project_s_End_date__c
FROM Project__c
WHERE Id = : projectId];
}
else
{
this.ProjectRec= new Project__c ();
}
}
public PageReference page2(){
system.debug('Hi am here!!!!!!!');
return Page.Project2;
}
}
Page 1:-
<apex:page standardController="Project__c" extensions="Project1" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="Project Details" >
<apex:inputField value="{!Project__c.Name}" id="name" required="true"/><br></br>
<apex:inputField value="{!Project__c.Description__c}" id="des"/><br></br>
<apex:inputField value="{!Project__c.Area_of_focus__c}" id="aof"/><br></br>
<apex:inputField value="{!Project__c.Expected_Output_Outcomes__c}" id="eoo"/><br></br>
<apex:inputField value="{!Project__c.Achievements__c}" id="achi"/><br></br>
<apex:inputField value="{!Project__c.Country__c}" id="country"/><br></br>
<apex:inputField value="{!Project__c.Budget__c}" id="bud"/><br></br>
<apex:inputField value="{!Project__c.Project_s_Start_date__c}" id="psd"/><br></br>
<apex:inputField value="{!Project__c.Project_s_End_date__c}" id="ped"/><br></br>
</apex:pageblockSection> </apex:pageBlock> </apex:form>
<apex:pageblock > <apex:pageBlockButtons location="bottom">
<apex:form > <apex:commandButton action="{!page2}" value="Save"/>
<apex:commandButton action="{!}" value="Save & new"/>
<apex:commandButton action="{!}" value="Cancel"/> </apex:form>
</apex:pageBlockButtons> </apex:pageBlock>
Page 2:-
<apex:page standardController="Project__c" extensions="Project1" >
<apex:form > <apex:pageBlock >
<apex:pageBlockSection title="Organizational Contact Details">
<apex:outputField value="{!Project__c.Name}" id="name" /><br></br>
<apex:outputField value="{!Project__c.Description__c}" id="des"/><br></br>
<apex:outputField value="{!Project__c.Area_of_focus__c}" id="aof"/><br></br>
<apex:outputField value="{!Project__c.Expected_Output_Outcomes__c}" id="eoo"/><br></br>
<apex:outputField value="{!Project__c.Achievements__c}" id="achi"/><br></br>
<apex:outputField value="{!Project__c.Country__c}" id="country"/><br></br>
<apex:outputField value="{!Project__c.Budget__c}" id="bud"/><br></br>
<apex:outputField value="{!Project__c.Project_s_Start_date__c}" id="psd"/><br></br>
<apex:outputField value="{!Project__c.Project_s_End_date__c}" id="ped"/><br></br>
</apex:pageBlockSection> </apex:pageBlock>
<apex:pageBlock > <apex:pageblockSection title="Project Team">
<apex:commandButton action="{!}" value="Add Project Team"/>
<apex:commandButton action="{!}" value="Edit"/> </apex:pageblockSection> </apex:pageblock> </apex:form> </apex:page>
public with sharing class Project1 {
public Project1() {
}
//Declaration
private ApexPages.StandardController controller;
public Project__c proj{get;set;}
public String projectId{get;set;}
public Id currentProjectId{get; set;}
public Project__c ProjectRec{get;set;}
public boolean isRendered{get;set;}
public boolean isNew_s{get;set;}
//Constructor
public Project1(ApexPages.StandardController stdController) {
projectId = ApexPages.currentPage().getParameters().get('Id');
if(projectId != null)
{
this.ProjectRec= [ SELECT Name,
Description__c,
Area_of_focus__c,
Expected_Output_Outcomes__c,
Achievements__c,
Country__c,
Budget__c,
Project_s_Start_date__c,
Project_s_End_date__c
FROM Project__c
WHERE Id = : projectId];
}
else
{
this.ProjectRec= new Project__c ();
}
}
public PageReference page2(){
system.debug('Hi am here!!!!!!!');
return Page.Project2;
}
}
Page 1:-
<apex:page standardController="Project__c" extensions="Project1" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="Project Details" >
<apex:inputField value="{!Project__c.Name}" id="name" required="true"/><br></br>
<apex:inputField value="{!Project__c.Description__c}" id="des"/><br></br>
<apex:inputField value="{!Project__c.Area_of_focus__c}" id="aof"/><br></br>
<apex:inputField value="{!Project__c.Expected_Output_Outcomes__c}" id="eoo"/><br></br>
<apex:inputField value="{!Project__c.Achievements__c}" id="achi"/><br></br>
<apex:inputField value="{!Project__c.Country__c}" id="country"/><br></br>
<apex:inputField value="{!Project__c.Budget__c}" id="bud"/><br></br>
<apex:inputField value="{!Project__c.Project_s_Start_date__c}" id="psd"/><br></br>
<apex:inputField value="{!Project__c.Project_s_End_date__c}" id="ped"/><br></br>
</apex:pageblockSection> </apex:pageBlock> </apex:form>
<apex:pageblock > <apex:pageBlockButtons location="bottom">
<apex:form > <apex:commandButton action="{!page2}" value="Save"/>
<apex:commandButton action="{!}" value="Save & new"/>
<apex:commandButton action="{!}" value="Cancel"/> </apex:form>
</apex:pageBlockButtons> </apex:pageBlock>
Page 2:-
<apex:page standardController="Project__c" extensions="Project1" >
<apex:form > <apex:pageBlock >
<apex:pageBlockSection title="Organizational Contact Details">
<apex:outputField value="{!Project__c.Name}" id="name" /><br></br>
<apex:outputField value="{!Project__c.Description__c}" id="des"/><br></br>
<apex:outputField value="{!Project__c.Area_of_focus__c}" id="aof"/><br></br>
<apex:outputField value="{!Project__c.Expected_Output_Outcomes__c}" id="eoo"/><br></br>
<apex:outputField value="{!Project__c.Achievements__c}" id="achi"/><br></br>
<apex:outputField value="{!Project__c.Country__c}" id="country"/><br></br>
<apex:outputField value="{!Project__c.Budget__c}" id="bud"/><br></br>
<apex:outputField value="{!Project__c.Project_s_Start_date__c}" id="psd"/><br></br>
<apex:outputField value="{!Project__c.Project_s_End_date__c}" id="ped"/><br></br>
</apex:pageBlockSection> </apex:pageBlock>
<apex:pageBlock > <apex:pageblockSection title="Project Team">
<apex:commandButton action="{!}" value="Add Project Team"/>
<apex:commandButton action="{!}" value="Edit"/> </apex:pageblockSection> </apex:pageblock> </apex:form> </apex:page>
1.Controller1 extend virtual class
2.Controller2 extend virtual class.
So now even if u move from 1 page to another page, the values in virtual class will be retained.