You need to sign in to do that
Don't have an account?
Eyal
How to override a standard controller action using an extension ?
Hello,
In order to let my user return to the same page after saving , I added an extension to the standard controller that changes the save action to return null. This is my extension class:
public class ExstensionControlerUserVideo {
private final User_Video__c UserVideo;
public ExstensionControlerUserVideo(
ApexPages.StandardSetController Controller) {
this.UserVideo = (User_Video__c)Controller.getRecord();
}
public PageReference Save() {
Update UserVideo;
return null; // redirect to same page
}
}
However, my page still redirects the user to another page.
Do I need to change the save action tag in the visual force page also ?
Currently it is like this:
Thanks a lot,
Eyal
this.UserVideo = (User_Video__c)Controller.getRecord();
}
public PageReference Save() {
Update UserVideo;
return null; // redirect to same page
}
}
However, my page still redirects the user to another page.
Do I need to change the save action tag in the visual force page also ?
Currently it is like this:
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
Thanks a lot,
Eyal
Hi,
The below is the workin code:
Apex Code:
Visualforce page:
return NULL will not navigate user to another page.
Hope this helps.
Thanks,
Devendra
All Answers
Have you specified extension class in <apex:page> tag?
Please check for the same.
Thanks,
Devendra
Yes,
I did like this:
Then it should have worked for you.
Try removing recordsetVar attribute from <apex:page> tag.
Hope this helps.
Thanks,
Devendra
When I try to remove it and save I get the following error :
Error: Unknown constructor 'ExstensionControlerUserVideo.ExstensionControlerUserVideo(ApexPages.StandardController controller)'
Why ?
Thanks,
Eyal
Hi,
The below is the workin code:
Apex Code:
Visualforce page:
return NULL will not navigate user to another page.
Hope this helps.
Thanks,
Devendra
Thanks a lot !!
it worked