Quick Reference Study Notes for Salesforce VisualForce Programming (Advanced)

Salesforce VisualForce Programming

Basic Features:

  • Visualforce is a Component based user interface.

  • Visualforce framework is the part of Salesforce’s Force.com Platform as a Service(PaaS).

  • It is a tag based markup language that is used in the Salesforce in order to extend the inbuilt features of the Salesforce.

  • Dynamic Visualforce Pages can be created by using the Visualforce Markup and Visualforce Controller.

 

Basic Structure:

<apex:page controller=”Name of the custom controller”>

<apex:form>

--All tags used within the apex page tag--

</apex:form>

</apex:page>

 

Tags:

apex:page Tag: This is the important and main tag of the Visualforce page and all other visualforce tags/elements are enclosed within this tag.

Syntax:

Without Attributes:

<apex:page>----all tags enclosed within this tag------</apex:page>

With Attributes:

<apex:page controller="" sidebar="" id="" tabStyle="Producer__c" renderAs="" action="" extensions="" showHeader="">

-----all tags enclosed within this tag-----

</apex:page>

 

Apex Page Attributes:

Attribute Name

Attribute Type

Description

id

String

Any String that uniquely define the Page that is used to reference the page in any component.

name

String

The unique name that is used to reference the page in the Force.com API.

standardController

String

The name of the Salesforce object that’s used to control the behavior of this page. This attribute can’t be specified if the controller attribute is also present.

controller

String

The name of the custom controller class written in Apex used to control the behavior of this page. This attribute can’t be specified if the standardController attribute is also present.

extensions

String

The name of one or more custom controller extensions written in Apex that extends functionality of this page.

showHeader

Boolean

A Boolean value that specifies whether the standard Salesforce tab header is included in the page.Set showHeader to TRUE in order to display header.

sidebar

Boolean

A Boolean value that specifies whether the standard Salesforce sidebar is included in the page. Set sidebar to TRUE in oredr to display sidebar.

tabStyle

String

The Salesforce object or custom Visualforce tab that controls the color, styling, and selected tab for this page.

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.

action

ApexPages.Action

The action method invoked when this page is requested by the server.

Example: action="{!processAction}" references the processAction() method in the controller.

title

String

It is used to set the window or tab title for the page.


 

apex: pageblock Tag: An area of a Page which uses the structure of the Salesforce’s  standard detail pages. We can create as many Pageblocks as we want inside a Visualforce page.

 

Syntax:

<apex:pageBlock title="page block title" mode="edit">

</apex:pageBlockSection>

<apex:pageBlockSectionItem>

---Write other tags here----

</apex:pageBlockSectionItem>

</apex:pageBlockSection>

</apex:pageBlock>

 

</apex:page>

 

Pageblock tag Attributes:

Attribute Name

Attribute Type

Description

title

String

The text displayed as the title of the page block.

mode

String

The default user mode for the pageBlock component's child elements. This value determines whether lines are drawn separating field values. Possible values are: detail,maindetail,edit,inlineEdit.

id

String

An identifier that allows the pageBlock component to be referenced by other components in the page.

tabStyle

String

It includes Salesforce object or custom Visualforce tab that controls the color scheme of the page block.

rendered

Boolean

It specifies whether the component is rendered on the page. Default value is TRUE.


 

Pageblock Child Elements:

  • apex:pageBlockSection: This element is a direct child of <apex:pageBlock> component, which is similar to the section of standard Salesforce page layout. It consists of one or more columns and each column includes two cells:

    • Cell1: stores field’s label.

    • Cell2: stores field’s value.

  • apex:pageBlockSectionItem: It is the direct child of the apex:pageBlockSection element and it consist of one column that include label and its value.

  • apex:pageBlockButtons: It is used for placing a button on top and bottom of the pageblock.

  • apex:pageBlockTable: It is used to display the data in the table.

 

apex:commandButton Tag: This button is used to execute the action/method of the controller and after execution, it will refresh the vf page or redirect the page to another page/URL. It must be the child of the apex:form element.

 

Syntax:

<apex:commandButton action="{!executeMethod}" value="Execute" id="theButton"/>

 

 

apex:selectList Tag: This tag is used to display multiple values in the dropdown list and allow users to select either one or more values from the list.

 

Syntax:

<apex:selectList value="{!listOfCityCode}" multiselect="true">
  <apex:selectOptions value="{!cityCode}"/>
</apex:selectList>



 

Other Tags:

 

Tag

Description

apex:actionFunction

It is used where user wants to call controller method directly from javascript.

flow:interview

This is used to add a Flow inside VF Page.

apex:outputLink

It is used to make the text/image Link. When we click on this link, it will redirect us to specified URL.

apex:param

It is used to send parameter for other components such as actionFunction,apex:actionSupport,apex:commandLink,flow:interview etc.

apex:actionPoller

It is used to send the request to the server after a specified time interval. It refreshes the particular region after a specific time interval

apex:component

This is used to create the custom component in the Salesforce. Example of using this component in a VF Page:

<c:customComponent/>

Where customComponent is the name of the custom component.

apex:inputField

This tag is used to display the value of the any field of any Object record.

 

*NOTE : "This study material is collected from multiple sources to make a quick refresh course available to students."

This website uses cookies to improve user experience. By using our website you consent to all cookies in accordance with our Cookie Policy. More info. I Agree