Newer Version Available
Understanding the MassUpdateStatus Visualforce Markup
<apex:page>
As with all Visualforce pages, the MassUpdateStatus page must begin with an <apex:page> component. Notice the tag has the same standardController attribute used in our interactive Candidate Map feature, although this time it is set to the Job Application object (Job_Application__c). This makes sense because the Mass Update Status feature updates a field on job application records, not position records.
The component also has a recordSetVar attribute. We use this attribute to change the standardcontroller so that it accommodates a set of records rather than a single record.
<apex:sectionHeader>
The <apex:sectionHeader> component adds a header to the top of the page. The component's title attribute determines the text in the header.
<apex:form>
The <apex:form> component establishes a section on the page in which users can enter data and submit it by clicking a button or link. It's like an invisible container, similar to a <form> element in HTML.
<apex:pageBlock>
The <apex:pageBlock> component designates an outlined area on the page similar to the areas on detail pages that contain sections.
<apex:pageMessages>
The <apex:pageMessages> component allocates space for standard system messages (such as those that notify users when a file is being saved) and validation rule errors. These messages already exist in the Lightning platform, so you don't have to create them—you just have to use this component to make room for them in case the platform needs to display them.
<apex:pageBlockButtons>
The <apex:pageBlockButtons> component allocates space for a set of buttons on the page. Its subcomponents specify what the buttons do and how they are labeled.
<apex:commandButton>
Each <apex:commandButton> component creates an individual button inside the <apex:pageBlockButtons> component. The Mass Update Status page uses two <apex:commandButton> components: one to create a Save button and a second to create a Cancel button. The buttons are styled like standard Salesforce buttons.
The value attribute on the <apex:commandButton> component determines the words that appear on the button (such as “Save” or “Cancel”), while the action attribute determines the operation that occurs when the button is clicked. When setting the action attribute, you must use merge field syntax. For example, to configure the button to save the data entered on the page, set the action attribute to {!save}.
Each button appears twice on our MassUpdateStatus page—once at the top of the area allocated by the <apex:pageBlock> component and once at the bottom. This is a precautionary measure built into the <apex:pageBlockButtons> component to ensure that the button functionality is apparent to users, even if the page block is large.
<apex:pageBlockSection>
The <apex:pageBlockSection> component can be used within <apex:pageBlock> components to create a section on a page similar to the sections found on page layouts. On this page, the <apex:pageBlockSection> component is used twice.
The first instance of the <apex:pageBlockSection> component has a title attribute that's set to "Status Update." This text will appear at the top of the section. It also has a collapsible attribute that determines whether users can collapse and expand the section by clicking an arrow to the left of the title. We don't want users to accidentally collapse this page block section, so the attribute is set to “false.”
<apex:inputField>
The <apex:inputField> component renders the Status field from the Job Application object on our page. Use <apex:inputField> components to create HTML input elements for any Salesforce field. All you need to do is set the component's value attribute to the API name of the Salesforce object and field.
<apex:pageBlockTable>
The <apex:pageBlockTable> component renders a table containing field values from multiple records of a specific object. For our feature, we need to set two of this component's attributes: value and var.
The value attribute tells the table which set of records contains the values to display. In this instance, we set the attribute to the expression {!selected} to enable the table to display values from the selected job applications.
The second attribute, var, creates a name that components within the table can use to reference individual records in the record set without actually referring to each record by name.
<apex:column>
1{!application.name}1<apex:column headerValue="Candidate Name">
2 <apex:outputText value="{!application.
3 candidate__r.First_Name__c & ' ' &
4 application.candidate__r.Last_Name__c}"/>
5</apex:column>When you generate column fields in this manner, the value attribute on the <apex:column> component is not set, so the table doesn't know what to use as the column header. Rectify this by setting the headerValue attribute on this <apex:column> component.
Beyond the Basics
Did you know you can add a Chatter feed to a Visualforce page?
1<apex:page standardController="Position__c">
2 <chatter:feed entityId="{$!Position__c.id}">
3 <apex:detail />
4</apex:page>To find out more, see the Visualforce Developer's Guide.