You need to sign in to do that
Don't have an account?
Ravi kumar 292
How to fetch values from one controller to another
Hi All,
I have created two visualforce pages. One with command button. When i click on button it will redirect to the second vf page. In first vf page controller am fetching the contact fields. Now i want to use those contact fields in second vf page controller. How to do this.. below is my vf pages and its controllers.
VF Page : 1
<apex:page standardController="Contact" extensions="TestController">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:commandButton value="Login" action="{!Login}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller : 1
public with sharing class TestController {
Private Contact con;
public YodleeController(ApexPages.StandardController controller) {
String ConId = ApexPages.CurrentPage().getparameters().get('id');
Contact con = [Select id, FirstName, LastName, PAN_ID__c from Contact where id=:ConId];
system.debug('conId--'+con.id);
system.debug('conPAN---'+con.PAN_ID__c);
}
public PageReference Login() {
PageReference page = new PageReference('/apex/LinkAccess');
page.setRedirect(true);
return page;
}
}
VF Page : 2
<apex:page controller="LinkAccessController">
<HTML>
<HEAD>
</HEAD>
<BODY>
<form action="https://test.com/" method="POST" id="sessionPost"><br/><br/>
app Id
<input type="text" name="app" /><br/><br/>
session
<input type="text" name="rsession" /> <br/><br/>
tokenID
<input type="text" name="token" /> <br/><br/>
Redirect Required
<input type="text" name="redirectReq" placeholder="true" value="True"/><br/><br/>
<script>document.getElementById('sessionPost').submit();</script>
</form>
</BODY>
</HTML>
</apex:page>
Controller : 2
public with sharing class LinkAccessController {
// Some code is there..
// Here i want use the contact fields from first controller to do some operation
}
I have created two visualforce pages. One with command button. When i click on button it will redirect to the second vf page. In first vf page controller am fetching the contact fields. Now i want to use those contact fields in second vf page controller. How to do this.. below is my vf pages and its controllers.
VF Page : 1
<apex:page standardController="Contact" extensions="TestController">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:commandButton value="Login" action="{!Login}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller : 1
public with sharing class TestController {
Private Contact con;
public YodleeController(ApexPages.StandardController controller) {
String ConId = ApexPages.CurrentPage().getparameters().get('id');
Contact con = [Select id, FirstName, LastName, PAN_ID__c from Contact where id=:ConId];
system.debug('conId--'+con.id);
system.debug('conPAN---'+con.PAN_ID__c);
}
public PageReference Login() {
PageReference page = new PageReference('/apex/LinkAccess');
page.setRedirect(true);
return page;
}
}
VF Page : 2
<apex:page controller="LinkAccessController">
<HTML>
<HEAD>
</HEAD>
<BODY>
<form action="https://test.com/" method="POST" id="sessionPost"><br/><br/>
app Id
<input type="text" name="app" /><br/><br/>
session
<input type="text" name="rsession" /> <br/><br/>
tokenID
<input type="text" name="token" /> <br/><br/>
Redirect Required
<input type="text" name="redirectReq" placeholder="true" value="True"/><br/><br/>
<script>document.getElementById('sessionPost').submit();</script>
</form>
</BODY>
</HTML>
</apex:page>
Controller : 2
public with sharing class LinkAccessController {
// Some code is there..
// Here i want use the contact fields from first controller to do some operation
}
Hi Ravi kumar,
We can use sames controller for two visual force pages. In this case we can display as below
So that you can display Contact fields in vf page2.
Thanks,
Jagadeesh
When i click on button on VF1 it will redirect to the VF2 and it automatically redirect to the 3rd party(vendor). So how can i fetch the fields???
And as per your sample code extensions is controller of first vf page??
Am confused.. pls brief about this..
Thanks,
Hi Ravi kumar,
When i click on button on VF1 it will redirect to the VF2 and it automatically redirect to the 3rd party(vendor). So how can i fetch the fields???
I didn't understand the exact scenario here, What i understood i'm providing here.
I think some action we need to perform in VFpage 2 else i hope onload we need to call.
And as per your sample code extensions is controller of first vf page??
yes , we are providing vf page 1 Extensions (i.e controller) to vf page 2. So that we can access fields in your scenario.
Thanks,
Jagadeesh