标准save()
方法可以使用ApexPages.StandardController
. 这是一个如何实现它的简单示例:
顶点页面:
<apex:page standardController="Account" extensions="AccountExtension">
<apex:form >
<apex:pageMessages />
<apex:pageBlock title="Account">
<apex:pageBlockSection title="Account Details">
<apex:inputField value="{!account.Name}" />
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!Save}" value="save" />
<apex:commandButton action="{!Cancel}" value="cancel" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
扩展类:
public class AccountExtension {
ApexPages.StandardController stdController;
public AccountExtension(ApexPages.StandardController controller) {
stdController = controller;
}
public PageReference save() {
stdController.save(); // calling standard save() method
return null; // return 'null' to stay on same page
}
}