You need to sign in to do that
Don't have an account?

How to pass values from one VFpage to another VFpage
Here I am trying to pass id value from first page (pageonepagetwo) to another page (pagetwo), by clicking the button in page one i want to pass the id value to the pagetwo, in pagetwo i am having the table, this table need to display the contacts based on the account id
page one:(pageonepagetwo)
<apex:page controller="PageOne">
<apex:form >
<apex:pageblock >
<apex:pageblocksection >
<apex:commandButton value="Show Table" action="{!showTable}"/>
</apex:pageblocksection>
</apex:pageblock>
</apex:form>
</apex:page>
******controller*******
public class PageOne
{
public void showTable()
{
PageReference pr;
pr = Page.pagetwo; // use the name of the second VF page
pr.setRedirect(true);
pr.getParameters().put('id','00190000015yBQ6');
}
}
Second two: (pagetwo)
<apex:page controller="Secondtwo">
<apex:pageblock title="TableData Based on another page">
<apex:pageblocktable value="{!TableData}" var="data">
<apex:column >{!data.name}</apex:column>
</apex:pageblocktable>
</apex:pageblock>
</apex:page>
******** controller***************
public class Secondtwo
{
public list<contact> TableData{set;get;}
public Secondtwo()
{
TableData=[select name from contact where accountid=:ApexPages.currentPage().getParameters().get('id')];
}
}
page one:(pageonepagetwo)
<apex:page controller="PageOne">
<apex:form >
<apex:pageblock >
<apex:pageblocksection >
<apex:commandButton value="Show Table" action="{!showTable}"/>
</apex:pageblocksection>
</apex:pageblock>
</apex:form>
</apex:page>
******controller*******
public class PageOne
{
public void showTable()
{
PageReference pr;
pr = Page.pagetwo; // use the name of the second VF page
pr.setRedirect(true);
pr.getParameters().put('id','00190000015yBQ6');
}
}
Second two: (pagetwo)
<apex:page controller="Secondtwo">
<apex:pageblock title="TableData Based on another page">
<apex:pageblocktable value="{!TableData}" var="data">
<apex:column >{!data.name}</apex:column>
</apex:pageblocktable>
</apex:pageblock>
</apex:page>
******** controller***************
public class Secondtwo
{
public list<contact> TableData{set;get;}
public Secondtwo()
{
TableData=[select name from contact where accountid=:ApexPages.currentPage().getParameters().get('id')];
}
}
public class PageOne
{
public PageReference showTable()
{
PageReference url=new PageReference('/apex/pagetwo?id=00190000015yBQ6');
return url;
}
}
All Answers
public class PageOne
{
public PageReference showTable()
{
PageReference url=new PageReference('/apex/pagetwo?id=00190000015yBQ6');
return url;
}
}