apex:page

A single Visualforce page. All pages must be wrapped inside a single page component tag.

This component supports HTML pass-through attributes using the "html-" prefix. Pass-through attributes are attached to the generated <html> tag.

Example

<!-- Page: -->
                        
<apex:page renderAs="pdf"> <style> body { font-family: 'Arial Unicode MS'; } </style> <h1>Congratulations</h1> <p>This is your new PDF</p> </apex:page>

Attributes

Attribute Name Attribute Type Description Required? API Version Access
action ApexPages.Action The action method invoked when this page is requested by the server. Use expression language to reference an action method. For example, action="{!doAction}" references the doAction() method in the controller. If an action is not specified, the page loads as usual. If the action method returns null, the page simply refreshes. This method will be called before the page is rendered and allows you to optionally redirect the user to another page. This action should not be used for initialization. 10.0 global
apiVersion double The version of the API used to render and execute the page. 10.0 global
applyBodyTag Boolean A Boolean value that specifies whether or not Visualforce should automatically add a <body> tag to the generated HTML output. Set to false to disable adding the <body> tag to the response, for example, when the <body> tag is statically set in your markup. If not specified, this value defaults to the value of the applyHtmlTag attribute if it's set, or true, if applyHtmlTag isn't set. 27.0
applyHtmlTag Boolean A Boolean value that specifies whether or not Visualforce should automatically add an <html> tag to the generated HTML output. Set to false to disable adding the <html> tag to the response, for example, when the <html> tag is statically set in your markup. If not specified, this value defaults to true. 27.0
cache Boolean A Boolean value that specifies whether the browser should cache this page. If set to true, the browser caches the page. If not specified, this value defaults to false. For Force.com Sites pages, if this attribute is not specified, this value defaults to true. For details on caching site pages, see "Caching Force.com Sites Pages" in the Salesforce online help. 10.0 global
contentType String The MIME content type used to format the rendered page. Possible values for this attribute include "text/html", "image/png", "image/gif", "video/mpeg", "text/css", and "audio/basic". For more information, including a complete list of possible values, see the W3C specifications.

You can also define the filename of the rendered page by appending a "#", followed by the file name to the MIME type. For example, "application/vnd.ms-excel#contacts.xls". Note: some browsers will not open the resulting file unless you specify the filename and set the cache attribute on the page to "true".

10.0 global
controller String The name of the custom controller class written in Apex used to control the behavior of this page. This attribute cannot be specified if the standardController attribute is also present. 10.0 global
deferLastCommandUntilReady Boolean A Boolean value that specifies whether to prevent premature clicking on command buttons and links. If true, the last click on a button or link will be enqueued and processed when page is ready. This value defaults to false. 26.0
docType String The HTML document type definition (DTD), or doctype, that describes the structure of the rendered page. If not specified, this value defaults to "html-4.01-transitional", which results in a doctype of <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">. Possible values for this attribute include "html-4.01-strict", "xhtml-1.0-transitional", "xhtml-1.1-basic", and "html-5.0", among others.

For more information about HTML doctype declarations, see the W3C specifications.

23.0
expires Integer The expiration period for the cache attribute in seconds. If the cache attribute is set to true, but this attribute is not specified, this value defaults to zero. For Force.com Sites pages, if cache is not set to false, this value defaults to 600 seconds. For details on caching site pages, see "Caching Force.com Sites Pages" in the Salesforce online help. 14.0
extensions String The name of one or more custom controller extensions written in Apex that add additional logic to this page. 11.0 global
id String An identifier for the page that allows it to be referenced by other components in the page. 10.0 global
label String The label that is used to reference the page in Salesforce setup tools. 10.0 global
language String The language used to display labels that have associated translations in Salesforce. This value overrides the language of the user viewing the page. Possible values for this attribute include any language keys for languages supported by Salesforce, for example, "en" or "en-US". 10.0 global
manifest String Adds a manifest attribute to the generated <html> tag, which references a cache manifest file for offline use. Setting a manifest attribute requires also setting docType="html-5.0", and applyHtmlTag to not be set to "false". 27.0
name String The unique name that is used to reference the page in the Force.com API. 10.0 global
pageStyle String The pageStyle attribute was deprecated in Salesforce API version 16.0 and has no effect on the page. 10.0 global
readOnly Boolean A Boolean value that enables read-only mode for a Visualforce page. In read-only mode, a page may not execute any DML operations, but the limit on the number of records retrieved is relaxed from 50,000 to 1 million rows. It also increases the number of items in a collection that can be handled by iteration components, from 1,000 to 10,000. If not specified, this value defaults to false. 23.0
recordSetName String The recordSetName attribute was deprecated in Salesforce API version 16.0 and has no effect on the page. Use recordSetVar instead. 14.0
recordSetVar String This attribute indicates that the page uses a set-oriented standard controller. The value of the attribute indicates the name of the set of records passed to the page. This record set can be used in expressions to return values for display on the page or to perform actions on the set of records. For example, if your page is using the standard accounts controller, and recordSetVar is set to "accounts", you could create a simple pageBlockTable of account records by doing the following:

<apex:pageBlockTable value="{!accounts}" var="a"><apex:column value="{!a.name}"/></apex:pageBlockTable>

14.0
renderAs String The name of any supported content converter. Currently PDF is the only supported content converter. Setting this attribute to "pdf" renders the page as a PDF.

Rendering a Visualforce page as a PDF is intended for pages that are designed and optimized for print. Standard components that aren't easily formatted for print or contain form elements like inputs, buttons, any component that requires JavaScript to be formatted, shouldn't be used. This includes but is not limited to, any component that requires a form element. Verify the format of your rendered page before deploying it.

If the PDF fails to display all the characters, adjust the fonts in your CSS to use a font that supports your needs. For example, add the following style definition to your page's styles:

body { font-family: 'Arial Unicode MS'; }

Note that the pageBlock and sectionHeader components don't support double-byte fonts when rendered as a PDF.

13.0 global
rendered Boolean A Boolean value that specifies whether the page is rendered. If not specified, this value defaults to true. 10.0 global
setup Boolean A Boolean value that specifies whether the page should use the style of a standard Salesforce setup page. If true, setup styling is used. If not specified, this value defaults to false. 10.0 global
showChat Boolean A Boolean value that specifies whether the Chatter Messenger chat widget is included in the page. If true, the chat widget is displayed. If not specified, the value defaults to the Visualforce Settings selected from Setup in Customize | Chatter | Chat Settings. 10.0 global
showHeader Boolean A Boolean value that specifies whether the Salesforce tab header is included in the page. If true, the tab header is displayed. If not specified, this value defaults to true. 10.0 global
sidebar Boolean A Boolean value that specifies whether the standard Salesforce sidebar is included in the page. If true, the sidebar is displayed. If not specified, this value defaults to true. 10.0 global
standardController String The name of the Salesforce object that is used to control the behavior of this page. This attribute cannot be specified if the controller attribute is also present. 10.0 global
standardStylesheets Boolean A Boolean value that specifies whether the standard Salesforce stylesheets are added to the generated page header if the showHeader attribute is set to false. If set to true, the standard stylesheets are added to the generated page header. If not specified, this value defaults to true. By setting this to false, components that require Salesforce.com CSS may not display correctly, and their styling may change between releases. 11.0 global
tabStyle String The Salesforce object or custom Visualforce tab that controls the color, styling, and selected tab for this page. If using a custom object, the attribute must be specified with the developer name for the object. For example, to use the styling associated with MyCustomObject, use tabStyle="MyCustomObject__c". If a standard controller is specified, this defaults to the style of the associated controller; if a custom controller is defined, this defaults to the Home tab (if a custom controller). To use a custom Visualforce tab, set the attribute to the name (not label) of the tab followed by a double-underscore and the word tab. For example, to use the styling of a Visualforce tab with the name Source and a label Sources, use tabStyle="Source__tab". 10.0 global
title String The title of the page as displayed in the browser. Note, when you are editing a page in developer mode, the page title will not be displayed. 10.0 global
wizard Boolean A Boolean value that specifies whether the page should use the style of a standard Salesforce wizard page. If true, wizard styling is used. If not specified, this value defaults to false. 10.0 global
© Copyright 2000–2014 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.