Data-driven styling

A useful technique when creating a custom user interface with Visualforce is to conditionally style important pieces of information to draw the user's attention to them as soon as a page is rendered.

Most Visualforce developers are familiar with using merge fields to provide sObject field values to output tags, or to decide if a section of a page should be rendered. In the tag shown next, the merge field, {!account.Name}, will be replaced with the contents of the Name field from the account sObject:

<apex:outputField value="{!account.Name}"/> 

The merge fields can also contain formula operators and be used to dynamically style data when it is displayed.

In this recipe, we will display a table of campaign records and style the campaign ...

Get Visualforce Development Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.