Apex and Visualforce Controllers: Page Block Sections and Field Components

Using Apex:PageBlockSection to Organize Data

Question

A section of data within an <apex:pageBlock> component, similar to a section in a standard Salesforce page layout definition.

An <apex:pageBlockSection> component consists of one or more columns, each of which spans two cells: one for a field's label, and one for its value.

Each component found in the body of an <apex:pageBlockSection> is placed into the next cell in a row until the number of columns is reached.

At that point, the next component wraps to the next row and is placed in the first cell.

To add a field from a Salesforce object to an <apex:pageBlockSection>, use an <apex:inputField> or <apex:outputField> component.

Each of these components automatically displays with the field's associated label.

To add fields for variables or methods that are not based on Salesforce object fields, or to customize the format of Salesforce object field labels, use an <apex:pageBlockSectionItem> component.

Each <apex:inputField>, <apex:outputField>, or <apex:pageBlockSectionItem> component spans both cells of a single column.

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

C.

The correct answer is C. apex:pageblockSection.

An <apex:pageBlockSection> component is used to create a section of data within an <apex:pageBlock> component. It is similar to a section in a standard Salesforce page layout definition.

An <apex:pageBlockSection> can consist of one or more columns, each of which spans two cells: one for a field's label and one for its value. Each component found in the body of an <apex:pageBlockSection> is placed into the next cell in a row until the number of columns is reached. At that point, the next component wraps to the next row and is placed in the first cell.

To add a field from a Salesforce object to an <apex:pageBlockSection>, use an <apex:inputField> or <apex:outputField> component. These components automatically display with the field's associated label.

To add fields for variables or methods that are not based on Salesforce object fields or to customize the format of Salesforce object field labels, use an <apex:pageBlockSectionItem> component. Each <apex:inputField>, <apex:outputField>, or <apex:pageBlockSectionItem> component spans both cells of a single column.

The other options mentioned in the question are:

A. <apex:outputLabel> is used to create a label for an input field or an output field.

B. <apex:actionPoller> is used to execute an action on the server at a regular interval, allowing the page to refresh its data without requiring user interaction.

D. <apex:facet> is used in conjunction with the <apex:dataTable> component to define a custom table header or footer.