Action methods perform logic or navigation when a page event occurs, such as when a user clicks a button, or hovers over an area of the page. Action methods can be called from page markup by using {! } notation in the action parameter of one of the following tags:
The following table describes the action methods that are supported by all standard controllers. You can associate these actions with any Visualforce component that includes an action attribute.
Action | Description |
---|---|
save | Inserts a new record or updates an existing record if it is currently in context. After this operation is finished, the save action returns the user to the original page (if known), or navigates the user to the detail page for the saved record. |
quicksave | Inserts a new record or updates an existing record if it is currently in context. Unlike the save action, this page does not redirect the user to another page. |
edit | Navigates the user to the edit page for the record that is currently in context. After this operation is finished, the edit action returns the user to the page where the user originally invoked the action. |
delete | Deletes the record that is currently in content. After this operation is finished, the delete action either refreshes the page or sends the user to tab for the associated object. |
cancel | Aborts an edit operation. After this operation is finished, the cancel action returns the user to the page where the user originally invoked the edit. |
list | Returns a PageReference object of the standard list page, based on the most recently used list filter for that object. For example, if the standard controller is contact, and the last filtered list that the user viewed is New Last Week, the contacts created in the last week are displayed. |
<apex:page standardController="Account"> <apex:form> <apex:pageBlock title="My Content" mode="edit"> <apex:pageBlockButtons> <apex:commandButton action="{!save}" value="Save"/> </apex:pageBlockButtons> <apex:pageBlockSection title="My Content Section" columns="2"> <apex:inputField value="{!account.name}"/> <apex:inputField value="{!account.site}"/> <apex:inputField value="{!account.type}"/> <apex:inputField value="{!account.accountNumber}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>