You need to sign in to do that
Don't have an account?
asd@as.asd
PageReference
hello,
i am bit confusing using these three methods. it's look like same or is there any deffernce among these methods.
plz help me
public PageReference next() {
PageReference pp=new PageReference('https://c.ap1.visual.force.com/apex/demoControllerPage1);
return pp;
}
public PageReference next() {
return Page.demoControllerPage1;
}
public PageReference next() {
PageReference acctPage = new ApexPages.StandardController(account).view();
acctPage.setRedirect(true);
return acctPage;
}
Page reference is returned in all three methods. But there are some differences in the way of the set the page to page reference.
1 st method : You have set the page by using actual URL. This is not recommened.
2nd method : You have use the just page name for set the page for pageReference.
3rd method : You have use standard controller and the view page layout of account object. Every object has standard controller with its methods and few page layouts. In 3rd method, you have used the view method of account object's standard controller.
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
sorry i am still confuse between first two.
is there any kind effect on controller.
i am using same controller for two different pages.
PAGE1
<apex:page controller="demoController1">
<apex:form >
<apex:pageBlock >
<apex:pageblocktable value="{!data}" var="acc">
<apex:column >
<apex:outputtext value="{!acc.name}" />
</apex:column>
</apex:pageblocktable>
</apex:pageBlock>
<apex:commandButton value="next" action="{!next}"/>
</apex:form>
</apex:page>
PAGE2
<apex:page controller="demoController1">
<apex:form >
<apex:pageBlock >
<apex:pageblocktable value="{!data1}" var="acc">
<apex:column >
<apex:outputtext value="{!acc.name}" />
</apex:column>
</apex:pageblocktable>
</apex:pageBlock>
</apex:form>
</apex:page>
CONTROLLER
public class demoController1 {
public list<Account> getData1() {
return acc;
}
list<Account> acc;
public PageReference next() {
PageReference pp=new PageReference('https://c.ap1.visual.force.com/apex/demoControllerPage1);
return pp;
// return Page.demoControllerPage1;
}
public list<Account> getData() {
acc=[select name from Account];
system.debug('AAAAAAAAAAAAAAAAAAAAAAA '+acc);
return acc;
}
}
if i use PageReference object then i cant get any value in page2 of page1
but if i used Page.demoControllerPage1 then i can get any value in page2 of page1
Refer following link
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_pages_pagereference.htm
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.