visualforce cheat sheet

Upload: mahendrakumar

Post on 07-Aug-2018

216 views

Category:

Documents


1 download

TRANSCRIPT

  • 8/20/2019 Visualforce Cheat Sheet

    1/2

    Visualforce Cheat SheUSER INTERFACE

    OverviewSalesforce1 platform provides Visualforce and Lightning frameworks to build customapplications. Visualforce uses extensible, "custom markup that ties closely with server sideSalesforce Apex technology to allow developers to rapidly build MVC web applications.

    Getting Started

    Enable Developer Mode by clicking Your Name | Setup | My Personal Information |Personal Information | Edit. Select the Development Mode checkbox to enable an inlineVisualforce editor. To create a page, navigate to a URL based on your current instance, like:

    https://.salesforce.com/apex/helloWorld 

    All Visualforce page markup lies within an tag. Here’s a simple page:

    Hello World

    All tags take an optional or required set of attributes, such asshowHeader above. Use theinline editor auto-completion, or the Component Reference, to determine the attributes forcomponents.

    List all Visualforce pages and Apex classes by navigating to Your Name | Setup | Develop.

    Example

    Visualforce supports auto-generated standard controllers, as well as extensions, to minimize theamount of coding needed. Here’s an example of a Visualforce page that uses a custom controller:

    action="{!action}" reRender="dynamic"/>

    {!theText}

    This Visualforce page displays an input field and a button labeled Go. When clicked, itsends the value of the field to the controller, which performs an action on it. Here, itduplicates the input. The page renders the result using an AJAX update. Here’s the controller:

    public class Hello {

    public PageReference action() {

    theText = theText + theText;

    return null;

    }

    public String theText {get;set;}

    }

    Core TagsHere are core tags that often make up a Visualforce page:

     The obligatory outer tag.

     A link to a JavaScript library, often in a static resource.

     A link to a CSS stylesheet, often in a static resource.

    Template SystemTemplate components let you create Visualforce pages that act as templates, having namedareas—inserts—that must be filled when the template is used.

    Declares a named area that must be defined.

     Adds the defined template.

    Provides content for the inserts.

    AJAX and JavaScript The reRender  attribute on action tags such as lets you refreshpart of a page. The following tags provide additional AJAX and JavaScript support:

    Define JavaScript functions to be called from JavaScript co

     A timer that sends an AJAX update request at specified inte

    Defines an area in a page that demarcates which componeshould be processed when AJAX requests generate.

     A component that displays the status of an AJAX update req

     Adds asynchronous refresh support to a component.

    Core FormHere are the core components used in forms. These should be embedded within a sing component on a page:

    Container for input components.

     A form button used to submit or reset a form.

     An HTML link that performs an action.

     An HTML input element of type checkbox.

    Input element that corresponds to a field on a standard orcustom object.

     An input field to upload a file.  An HTML input element of type hidden.

     An HTML input element of type password.

     An HTML input element of type text.

     An HTML input element of type text area.

     A list of options for radio buttons or checkboxes.

     A set of related radio button input elements, displayed in a t

     A possible value for the or components.

     A set of related checkbox input elements, displayed in a ta

     A collection of values for the ,, or components.

    Core OutputMirroring many of the Core Form Components, these components are used for outputting

     A read-only display of a label and value for fields on custom o

     A label for an input or output field.

     A link to a URL.

     A set of content that is grouped together, rendered with anHTML tag, tag, or neither.

    Displays styled or escaped text in a page.

    Tables and Lists Output These components are used to generate tables or lists by iterating over a collection:

     An HTML table.

     A single column in a table.

     An ordered or unordered list of values.

     A placeholder for content that is rendered in a specific par

    the parent component.  An HTML table element that lays out its components in

    consecutive cells.

     A container for multiple child components so that they cadisplayed in a single panelGrid cell.

    Miscellaneous HTML These components generate HTML for embedding flash, iframes and images:

     A Flash movie, rendered with object and embed tags.

    Creates an iframe in a page.

     A graphical image, rendered with an img tag.

    http://developer.salesfo

  • 8/20/2019 Visualforce Cheat Sheet

    2/2

    Miscellaneous VisualforceThese components provide Visualforce messages, iteration, and include functionality:

     An unformatted iteration component.

     A message for a specific component, such as a warning or error.

     All messages that were generated for all components on thecurrent page.

    Inserts a second Visualforce page into the current page.

    Lets parameters be fed into other components.

     An inline frame that displays an s-control.

     A local variable representing an expression.

    Default Look and FeelCRUD and other screens have a standard look and feel. The following componentsgenerate output that conforms to that look and feel:

     The standard detail page for a particular object.

     The list view picklist for an object, including its associatedlist of records.

     The list view picklist for an object, including its associatedlist of records.

     A list of records that are related to a parent record with alookup or master-detail relationship.

    Defines a visual block within a page.

    Defines buttons related to a block.

     A section of data within a component.

     A single piece of data in a thattakes up one column in one row.

     A list of data displayed as a table within either a or component.

    Displays custom messages.

    Displays all messages that were generated for allcomponents on the page.

     A page area that includes one or more tags that can expand.

     A section of a that can expand or collapse.

     A title bar for a page.

     A single tab in a .

     A page area that displays as a set of tabs.

     A toolbar that can contain any number of child components.  A group of components within a toolbar.

    Custom ComponentsCreate your own components that will reside in the c namespace, for example:

     The outer tag that starts the definition of a component.

     A definition of a typed attribute on a custom component.  A place holder for content injected into a component.

    SitesSites is based on Visualforce pages, and the the following tags provide additional functionality:

    Used to integrate Google Analytics.

    Shows detailed messages in administrator preview mode.

    MessagingVisualforce can also be used to create email templates:

     Appends an attachment to the email.

     Adds a custom header to the email.

    Defines a Visualforce email template.

     The HTML version of the email body.

     The plain text (non-HTML) version of the email body.

    Ideas Applications that integrate Ideas have additional components available:

     A link to the page displaying an idea.

     A link to the page displaying a list of ideas.

     A link to the page displaying a user's profile.

    Knowledge You can embed Knowledge functionality on your pages:

    UI component used when an article is openedfrom the case detail page.

     A loop on a filtered list of articles.

    Displays a header toolbar for an article.

     A loop on all available article types.

     A loop on a subset of the category hierarchy.

    Chatter Add Chatter UI widgets:

    Displays the Chatter feed for a record.

     An integrated UI component that displays the Chatterfor a record, as well as its list of followers.

    Renders a button for a user to follow or unfollow aChatter record.

    Displays the list of Chatter followers for a record.

    WorkflowComponents that present your process workflow:

    Embeds a Flow interview in the page.

    Global Variables These reference general information about the current user and your organization on aVisualforce page:

    $Action Reference standard actions on objects.

    $API Refer to API URLs or sessions IDs.

    $Component Reference a component from within, for example, JavaS

    $CurrentPage Reference name, parameters, URL of current page.

    $Label References a custom label.

    $ObjectType  Access metadata of objects.

    $Organization  Access information about the company profile.

    $Page  The way to reference a Visualforce page.$Resource Used for accessing static resources.

    $SControl References an existing custom s-control by name.

    $Site Reference site information, such as domain name.

    $System.OriginDateTime Represents the literal value of 1900-01-01 00:00:00.

    $User Information about the current user.

    $UserRole  The current user's role information.

    $Profile  The current user's profile.

    Static Resources

    Upload static resources, such as stylesheets and images, into a zip, and then reference tusing the URLFOR formula and $Resource merge field. For example, if you’ve uploadimages/Blue.jpg into a zip called TestZip, reference it like this:

    Apex SupportHere are Apex classes, available in the ApexPages namespace, which can be used toreference Visualforce functionality:

    Action Create and invoke actions on an object.

    Message Create messages to be displayed, usually for errors.

    PageReference  A reference to a Visualforce page.

    SelectOption Specifies one of the possible values for the selectCheckboxselectList, or selectRadio components.

    StandardController Reference the standard Visualforce controllers.

    StandardSetController Reference standard set controllers for iteration.

    10For other cheatsheets: http://developer.salesforce.com/cheatsheets