You need to sign in to do that
Don't have an account?
zubair shareef mohammad
Doubt in pagereference
Hi this is Zuber
I am written a code on navigating a page, but I cant execute
Please help me anyone
------------------------------------------
VF Page Code:
-------------
<apex:page sidebar="false" setup="false" showHeader="true" tabStyle="Customer__c" controller="SourcePageController" >
<apex:sectionHeader title="Source Page" subtitle="Page Navigation"/>
<apex:form >
<apex:pageblock title="Source Page Block">
<apex:pageblockSection title="Source Page Section" collapsible="false" columns="1">
<apex:inputtext label="Enter Customer Id : " value="{!customerId}"/>
<apex:inputtext label="Enter Customer Name: " value="{!customerName}"/>
<apex:commandButton value="Goto Target Page" action="{!GotoTargetPage}"/>
</apex:pageblockSection>
</apex:pageblock>
</apex:form>
</apex:page>
--------------------------------------------------------------------------------------
Controller Class:
-----------------
public class SourcePageController
{
Public string customerId{get;set;}
Public string customerName {get;set;}
Public PageReference GotoTargetPage()
{
//Pagereference pgRef = new PageReference('/apex/TargetPage?custId='+customerId +'&custName='+customerName);
PageReference pgRef = Page.TargetPage;
pgRef.getParameters().Put('custID',customerId);
pgRef.getParameters().Put('custName',CustomerNAme);
pgRef.SetRedirect(true);
return pgRef;
}
}
I am written a code on navigating a page, but I cant execute
Please help me anyone
------------------------------------------
VF Page Code:
-------------
<apex:page sidebar="false" setup="false" showHeader="true" tabStyle="Customer__c" controller="SourcePageController" >
<apex:sectionHeader title="Source Page" subtitle="Page Navigation"/>
<apex:form >
<apex:pageblock title="Source Page Block">
<apex:pageblockSection title="Source Page Section" collapsible="false" columns="1">
<apex:inputtext label="Enter Customer Id : " value="{!customerId}"/>
<apex:inputtext label="Enter Customer Name: " value="{!customerName}"/>
<apex:commandButton value="Goto Target Page" action="{!GotoTargetPage}"/>
</apex:pageblockSection>
</apex:pageblock>
</apex:form>
</apex:page>
--------------------------------------------------------------------------------------
Controller Class:
-----------------
public class SourcePageController
{
Public string customerId{get;set;}
Public string customerName {get;set;}
Public PageReference GotoTargetPage()
{
//Pagereference pgRef = new PageReference('/apex/TargetPage?custId='+customerId +'&custName='+customerName);
PageReference pgRef = Page.TargetPage;
pgRef.getParameters().Put('custID',customerId);
pgRef.getParameters().Put('custName',CustomerNAme);
pgRef.SetRedirect(true);
return pgRef;
}
}
I checked your code.. its working without having any issue. its redirected to spacified page(.TargetPage) with QueryString of CustomerID and Name). please refer image below. if you need something else let me know.
Hope this will clear.
Thanks
karthik
All Answers
I checked your code.. its working without having any issue. its redirected to spacified page(.TargetPage) with QueryString of CustomerID and Name). please refer image below. if you need something else let me know.
Hope this will clear.
Thanks
karthik
Hope this helps,
Controller:
public class SourcePageController {
Public string customerId{get;set;}
Public string customerName {get;set;}
Public PageReference GotoTargetPage() {
Pagereference pgRef = new PageReference('/apex/TargetPage?custId='+customerId +'&custName='+customerName);
pgRef.getParameters().Put('custID',customerId);
pgRef.getParameters().Put('custName',CustomerNAme);
pgRef.SetRedirect(true);
return pgRef;
}
}
Mark this answer as best if this helps.