You need to sign in to do that
Don't have an account?
can extension's save method call standard controller's save method.......
Hi Experts,
can i call standard controller's save action in my extension controller...
<apex:page standardcontroller="opportunity" extension="oppoExtesion"> <apex:form> <apex:pageblock> <apex:pageblockbutton> <apex:commandbutton value="Save" action="{!mysave}"/> </apex:pageblockbutton> <apex:inputfield value="{!opportunity.name}"/> <apex:inputfield value="{!opportunity.amount}"/> <apex:inputfield value="{!opportunity.closedate}"/> </apex:pageblock> </apex:form> </apex:page> ********Extension************* public class oppoextension { public pagereference mysave() { my validation check...... //Here i wnat to call standard controller's Save Action to perform the save operation as standard way... save(); } }
i want to experience standard salesforce validation check , field level security , profile base permission
as well as my custom validation through apex code
so how can i standard controller's Save from my extension's save method...
hi all,
i found the solution u can invoke the save of standard controller
public with sharing class oppoextension { public opportunity oppo; ApexPages.StandardController GstdController; // The extension constructor initializes the private member // variable acct by using the getRecord method from the standard // controller. public oppoextension(ApexPages.StandardController stdController) { GstdController = stdController; this.oppo= (opportunity)GstdController.getRecord(); } public pagereference mysave() { if(oppo.First_Name != 'amar') { oppo.adderror('Error'); } else { ApexPages.StandardController sc = new ApexPages.StandardController(stdController); PageReference pr = GstdController.save(); pageReference pv = GstdController.view(); return pv; } return null; } }
All Answers
hi all,
i found the solution u can invoke the save of standard controller
public with sharing class oppoextension { public opportunity oppo; ApexPages.StandardController GstdController; // The extension constructor initializes the private member // variable acct by using the getRecord method from the standard // controller. public oppoextension(ApexPages.StandardController stdController) { GstdController = stdController; this.oppo= (opportunity)GstdController.getRecord(); } public pagereference mysave() { if(oppo.First_Name != 'amar') { oppo.adderror('Error'); } else { ApexPages.StandardController sc = new ApexPages.StandardController(stdController); PageReference pr = GstdController.save(); pageReference pv = GstdController.view(); return pv; } return null; } }
Where are you doing upsert oppo? I don't see how the standard save() method knows anything about your oppo and it's fields...
This is absolute awesome man.........................