ApexPages Class

Use ApexPages to add and check for messages associated with the current page, as well as to reference the current page.

System

In addition, ApexPages is used as a namespace for the PageReference Class and the Message Class.

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

Add a message to the current page context.

public Void addMessage(ApexPages.Message message)

Type: Void

Adds a list of messages to the current page context based on a thrown exception.

public Void addMessages(Exception exceptionThrown)

Type: Void

Returns the current page’s PageReference.

public System.PageReference currentPage()

Type: System.PageReference

This code segment returns the id parameter of the current page.

Returns a list of the messages associated with the current context.

public ApexPages.Message[] getMessages()

Type: ApexPages.Message[]

Returns true if there are messages associated with the current context, false otherwise.

public Boolean hasMessages()

Type: Boolean

Returns true if messages of the specified severity exist, false otherwise.

public Boolean hasMessages(ApexPages.Severity severity)

Type: Boolean