Standard Controller and Standard list Controller in Salesforce.

The platform provides a few types of controllers

  1. Standard Controller
  2. Standard list Controller

Standard Controller – Every sObject has a standard controller with the Object Name.

Using Standard Controller –

<apex:page standardcontroller = “Account”></apex:page>  or

<apex:page standardcontroller = “Position__c”></apex:page>

NOTE– You cannot use the standardController and controller attributes at the same time.

In Visualforce pages, we can define the action attribute for the following standard Visualforce components:

  1. <apex:commandButton>
  2. <apex:commandLink>
  3. <apex:actionPoller>
  4. <apex:actionSupport>
  5. <apex:actionFunction>
  6. <apex:page>

A standard controller has a few standard action methods, as follows:

  1. save
  2. quicksave
  3. edit
  4. delete
  5. cancel
  6. list – This method redirects to the list view page by selecting the most

Standard List Controller –  is used for displaying or performing an action on a set of records. We can use standard list controllers for Account, Asset, Campaign, Case, Contact, Contract, Idea, Lead, Opportunity, Order, Product2, Solution, User, and all the custom objects.

Using Standard List Controller in VF page

Similar to the standard controller, we can specify the standardController attribute of the <apex:page> component. Additionally, we need to specify the recordSetVar attribute of the <apex:page> component.

The standardController attribute specifies the type of records that we want to access. The recordSetVar attribute indicates that the page uses a list controller and the variable name (used to access data in the record collection) of the record collection.

<apex:page standardController=”Account” recordSetVar=”accs”>
<apex:pageBlock >
<apex:pageBlockTable value=”{!accs}” var=”a”>
<apex:column value=”{!}”/>

Standard list controller actions

Below are the  action attribute can be used with a Visualforce page with a standard list controller.

  1. save
  2. quicksave
  3. List
  4. cancel
  5. first – displays the first page of records in the set.
  6. last – displays the last page of records in the set.
  7. next – displays the next page of records in the set.
  8. previous – displays the previous page of records in the set.

Pagination can be added to a page associated with a list controller.

Note – By default, a list controller returns 20 records per page. To control the number of records displayed on each page, use a controller extension to set the pageSize attribute.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s