+ Start a Discussion
AxxxVAxxxV 

Getting around Standard Controller Validation

I am having difficulty finding a good solution to the following problem:

I have an edit page for a standard object that uses a standard controller and a controller extension. The controller extension has the following method that I am intending to use in order to implement my custom page redirection logic when "cancel" action occurs on the page:

Code:
public PageReference cancel2(){
        PageReference targetPage;
String loopbackUrl = System.currentPageReference().getParameters().get('loopback');

if(loopbackUrl != null && loopbackUrl != ''){
targetPage = new PageReference(loopbackUrl);
targetPage.setRedirect(true);
return targetPage;
}
else{
return this.stdController.cancel();
}
}

Page
<apex:commandLink action="{!cancel2}" value="></apex:commandLink>

Problem is that when cancel2 action is invoked on the page, the standard controller validation display the error "Error: Name you must enter a value", and the page never gets to my custom cancel routine. What is the best way to get around this?

I also have other scenarios where standard controller validation prevents me from invoking various methods in the extension controller.



jwetzlerjwetzler
Please read the documentation for the immediate attribute on commandButton.
AxxxVAxxxV
Thanks a lot. This exactly was I was looking for.