function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nikvm257Nikvm257 

What is PageReference ??

Hello Guys ,

 

I am very new to cloud devlopment.

I am working on some vforce code devlopment.

I need to understand what is pagereference 

 

I have read the documentation but still couldn't clear myself.

 

So can  someone help me eunderstand in a layman terms what is the meaning of

 

}

public PageReference test() {
        return something; 
Thanks in advance !
Best Answer chosen by Admin (Salesforce Developers) 
Rahul SharmaRahul Sharma

By writing this:

public PageReference test() { 
return something; 
}

you define the return type of the is function which is page reference.

Pagereference is used if you want to redirect the current page to another page.
 

Refer this documentation or more details : Pagereference Class

 

In below example you will find we have defined a new Pagereference variable newPage with url of google, and we use that variable for redirecting with returning it.

public PageReference test() {
PageReference newpage = new PageReference('http://www.google.com'); 
newpage.setRedirect(true);
return newpage;
 

All Answers

Rahul SharmaRahul Sharma

By writing this:

public PageReference test() { 
return something; 
}

you define the return type of the is function which is page reference.

Pagereference is used if you want to redirect the current page to another page.
 

Refer this documentation or more details : Pagereference Class

 

In below example you will find we have defined a new Pagereference variable newPage with url of google, and we use that variable for redirecting with returning it.

public PageReference test() {
PageReference newpage = new PageReference('http://www.google.com'); 
newpage.setRedirect(true);
return newpage;
 
This was selected as the best answer
sandeep reddy 37sandeep reddy 37
thanks