Salesforce Standard Controllers - Salesforce

What is Salesforce Standard Controllers?

Visualforce comprises of many built-in controllers which can be used to entree and show data. It works on the MVC (model-view-controller) method. The controllers relate with the database and pull the data from the database to view the data over a webpage formed by apex page.
To show a precise record or group of records, we want the record ID. When integrated with other Visualforce pages the ID can flow to the controller page automatically. But in a standalone page we want to specify the record ID manually to see the controller working.

Example

Let us produce a Visualforce page to get the summary of a record in the Contact object. To do this, we use the component called standardController and put it in an apex block. The diagram given below displays the code to achieve this.

vf_s_controller_1

Here we show some choice fields from the Object. They are Name, Email and phone. If we go to the Preview window, we find that the page only shows the labels but no data. That is since we have not related the result from the controller with any precise record.

So next we classify a record form the Contact Object to be committed to the result from the controller. Open the contacts object and click on any of contact name. It will open the resulting window from which we capture the ID of the record. The ID is highlighted in the URL. In your environment, it will be a alike string of characters.

vf_s_controller_2

Lastly, we add this ID of the record to the URL of the preview window of the Visualforce standard controller page we created. In the present instance, the ID of the record is added as shown below.

On visiting the above URL from the Organization's salesforce account, we get the particulars of the record as revealed below.

vf_s_controller_3

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Salesforce Topics