+ Start a Discussion
DaniHellDaniHell 

How can I change the page by clicking the save button

How can I change the result page when i click on the save button.?

 

thank you

 

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

 

venkateshyadav1243venkateshyadav1243

use page reference in your visual force page.

vishal@forcevishal@force

Hi Daniel,

 

Your 'save'  which you're referring here should be a pageReference method. This will automatically redirect it to the reference you return in the method.

 

 

Example:

 

public pageReference goToHome()

{

     return new PageReference('/home/home.jsp');

}

 

calling this method as action on your button will redirect you to the Home Page.

DaniHellDaniHell

I have tried a lot of things, like the following code. It's not working

 

It changes always on the same default page.

 

public Pagereference goHome(){
			
	Pagereference to = Apexpages.currentPage();
         to.setRedirect(true);
	return to;
}

or 

public Pagereference goHome(){
			
	Pagereference to = new Pagereference('/apex/mypage?user=guest');	return to;
}


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

 

When I try it with an empty linked commandButton like this, it's changing the page to the default page too. Thats crazy. Any solution?

<apex:commandButton value="Save"  />