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
ravindraravindra 

How do I navigate from one Visualforce page to another?

Hi,

 

 I have a visualforce page created with some fields and a button basically a command button. Now I want to navigate to another page on click of the button i.e x page has button, on click of which i want to load the browser with page y. How do i do that?

 

 

Thanks in Advance,

Ravindra

Best Answer chosen by Admin (Salesforce Developers) 
ravindraravindra

No I found the solution for this

U jus need to put  action='/apex/Y' in the commandButton attribute. It will work.

 

Thanks for your time

All Answers

SuvraSuvra

Hi..

 

For that first you have to create two VF pages x and y. On click of the command button of page x, you need to mention the action, say "step2", which will be defined in the controller class like this :

 

public class sampleController{

 

public PageReference step1() {

return Page.pageX;

}

 

 

public PageReference step2() {

return Page.pageY;

}

 

}

 

 

Now, create page "pageX" :

 

<apex:page controller="sampleController">

<apex:form>

<apex:pageBlock>

 

<apex:pageBlockButtons>

<apex:commandButton action="{!step2}" value="Next"/>

</apex:pageBlockButtons>

 

</apex:pageBlock>

 

</apex:form>

</apex:page>

 

 

also, create page "pageY" :

 

 

<apex:page controller="sampleController">

<apex:form>

<apex:pageBlock>

 

<apex:pageBlockButtons>

<apex:commandButton action="{!save}" value="Save"/>

</apex:pageBlockButtons>

 

</apex:pageBlock>

 

</apex:form>

</apex:page>

ravindraravindra

Thanks for the reply, But its opening page Y in a different browser or in different tab. But I want it to be opened in the same brower. How do I do that?

 

SuvraSuvra

For that you have to add "standardController" or "controller" attribute in your Visual Force Page.

 

Suppose, you are adding like this in both the pages "pageX" and "pageY" :

 

<apex: page standardController="Account">

 

   Then both pages will open under Accounts Tab.

ravindraravindra

No I found the solution for this

U jus need to put  action='/apex/Y' in the commandButton attribute. It will work.

 

Thanks for your time

This was selected as the best answer
Ashok ChaudharyAshok Chaudhary
Solution for this problem.

http://sales-fundamentals.blogspot.in/2014/09/how-to-navigate-to-another-page-visual.html
Suneel B 9Suneel B 9
Hai ravindra i am new to visual force page. Can you please send me the apex class and the command button action u used exactly..
KONDA B 4KONDA B 4
Based on pick list values How to auto populate field values in apex page ?