Friday, April 2, 2010

Visualforce

Visualforce is a powerful tool for designing your forms with similar look and feel of Salesforce default layouts. Let’s say you want to build a search page for Account Object. That is you wish to list all the existing accounts in a list and search functionality by using which you want to view the filtered accounts.
To do the same functionality before Visualforce era, it was very cumbersome and demand more knowledge on javascript (which may not be reliable on all browsers). Visual force is the markup language introduced by Salesforce, It provides a similar look and feel of a Salesforce standard object by just introducing some tags whose namespace is prefixed by apex.
We can use the standard object properties and styles by just setting the attribute StandardController to the desired object like below
<apex:page standardController=”Account”></apex:page>

An example which uses Account as StandardController and renders Account style is below.
<apex:page standardController="Account">
<apex:form>
<apex:pageBlock title="Edit Account for{!$User.FirstName}">
<apex:pageBlockSection>
<apex:inputField value="{!account.name}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

The above code inherits a pageblock which is similar to Account standard layout page section with the Name field editable. If you observe the Pageblock’s title, we can still use the Formula Merge Fields just like in S-Controls.
In my next Article on Visualforce, I will be posting the code for the functionality described at top (Search functionality on Account listing). This will involve more abilities of Visualforce.

No comments:

Post a Comment