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
DaniHellDaniHell 

How can I overwrite the save button to change on a custom page

When I use the standard save action in the commandButton it goes every time to the default page.

But I want to chamge to a custom page when i click on the save button..how??

 

I tried a lot of things like this...

 

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}" />

 

 

Any solution??

MagulanDuraipandianMagulanDuraipandian

Sample Code:

 

Visualforce page:

 

<apex:page controller="sample">
            <apex:commandButton value="Open" action="{!openPage}"/>   
</apex:page>

 

Apex Class: 

 

public class sample
{
    public pageReference openPage()
    {
        pageReference pg = new pageReference('/apex/Name_Of_The_Page');
        pg.setRedirect(true);
        return pg;
    }      
}

 

https://sites.google.com/site/infallibletechie/how-to-open-another-visualforce-page-from-current-visualforce-page-in-salesforce

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

SFDC Blog

SFDC Site

If this post is your solution, kindly mark this as the solution.

 

DaniHellDaniHell
No it's not working in my context. I tried your code in an empty visualforce page.There it's running. I copied it in my visualforce page and there it's not working. The page changed to the url https://XX.XX.visual.force.com/apex/mobilepage?user =DA_HE#/apex/mobilepage. #/apex/mobilepage seeams to be a default page. On my page is using Jquery Mobile too.