---
schema_version: "1"
id: 5750ef23734d2b748b622944b712d6573d04975d5424d4b7019ba1e5ebf175f9
title: Action Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_pages_action.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_pages_action.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 2ee7e78aa7bc8d58a92ee2c01834c3d24e274c14a49d6c26ef8de796db2dfba5
description: You can use ApexPages.Action to create an action method that you can use in a Visualforce custom controller or controller extension.Creates a new instance of the ApexPages.Action class using the specified action.Returns the expression that is evaluated when the action is invoked.Invokes the action.
---
# Action Class

You can use ApexPages.Action to create an action method that you can use in a Visualforce custom controller or controller extension.

## Namespace

[ApexPages](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_ApexPages.htm "The ApexPages namespace provides classes used in Visualforce controllers.")

## Usage

For example, you could create a saveOver method on a controller extension that performs a custom save.

## Instantiation

The following code snippet illustrates how to instantiate a new ApexPages.Action object that uses the save action:

ApexPages.Action saveAction = new ApexPages.Action('{!save}');

- **[Action Constructors](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_pages_action.htm#apex_ApexPages_Action_constructors)**
- **[Action Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_pages_action.htm#apex_ApexPages_Action_methods)**

## Action Constructors

The following are constructors for Action.

- **[Action(action)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_pages_action.htm#apex_ApexPages_Action_ctor)**  
    Creates a new instance of the ApexPages.Action class using the specified action.

### Action(action)

Creates a new instance of the ApexPages.Action class using the specified action.

#### Signature

public Action(String action)

#### Parameters

- **action**: Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.") The action.

## Action Methods

The following are methods for Action. All are instance methods.

- **[getExpression()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_pages_action.htm#apex_ApexPages_Action_getExpression)**  
    Returns the expression that is evaluated when the action is invoked.
- **[invoke()](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_pages_action.htm#apex_ApexPages_Action_invoke)**  
    Invokes the action.

### getExpression()

Returns the expression that is evaluated when the action is invoked.

#### Signature

public String getExpression()

#### Return Value

Type: [String](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_string.htm#apex_methods_system_string "Contains methods for the String primitive data type.")

### invoke()

Invokes the action.

#### Signature

public System.PageReference invoke()

#### Return Value

Type: [System.PageReference](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_system_pagereference.htm "A PageReference is a reference to an instantiation of a page. Among other attributes, PageReferences consist of a URL and a set of query parameter names and values.")