Book Image

Visualforce Development Cookbook - Second Edition

By : Keir Bowden
Book Image

Visualforce Development Cookbook - Second Edition

By: Keir Bowden

Overview of this book

Visualforce is a framework that allows developers to build sophisticated, custom user interfaces that can be hosted natively on the Force.com platform. The Visualforce framework includes a tag-based markup language, similar to HTML that is used to write the Visualforce pages and a set of controllers that are used to write business logic to the Visualforce pages. Visualforce Development Cookbook provides solutions to a variety of challenges faced by Salesforce developers and demonstrates how easy it is to build rich, interactive pages using Visualforce. Whether you are looking to make a minor addition to the standard page functionality or override it completely, this book will provide you with the help you require throughout. You will start by learning about the simple utilities and will build up to more advanced techniques for data visualization and to reuse functionality. You will learn how to perform various tasks such as creating multiple records from a single page, visualizing data as charts, using JavaScript to enhance client-side functionality, building a public website, and making data available to a mobile device. With an interesting chapter on tackling common issues faced while developing Visualforce pages, the book provides lots of practical examples to enhance and extend your Salesforce user interface.
Table of Contents (16 chapters)
Visualforce Development Cookbook - Second Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface

Preface

The Visualforce framework allows developers to build highly customized, personalized, and branded user interfaces for their Salesforce, Force.com, and Salesforce1 applications. Hosted natively on the Salesforce platform, Visualforce gives developers complete control over all areas of the user interface, allowing them to satisfy complex business requirements and support multiple devices.   

Visualforce pages use a mixture of HTML and Visualforce components, which are processed server-side and delivered to the browser as HTML. This allows the use of standard web technologies, such as CSS and JavaScript, to provide an enriched and dynamic user experience.

The Visualforce Development Cookbook provides solutions for a variety of challenges faced by the Salesforce developers and demonstrates how easy it is to build rich interactive pages for both desktop and mobile devices using Visualforce. Each recipe contains clear, step-by-step instructions along with detailed explanations of the key areas of Visualforce, Apex or JavaScript code, that deliver the solution.

Whether you are looking to make a minor addition to the standard page functionality or override it completely, this book will provide you with practical examples that can be readily adapted to a number of scenarios.

What this book covers

Chapter 1 , General Utilities, covers enhancing or replacing standard functionality with Visualforce, systemizing business processes, guiding users through the creation and ongoing management of data, and writing effective tests.

Chapter 2, Custom Components, demonstrates how to create custom Visualforce components to encapsulate functionality for reuse across multiple pages and techniques to allow communication between component and page controllers.

Chapter 3, Capturing Data Using Forms, describes how to capture data entered in a Visualforce page and send this to the server for processing.

Chapter 4, Managing Records, offers techniques to streamline and enhance the management of Salesforce data using Visualforce pages, using styling to indicate required fields and changing pages in response to user actions.

Chapter 5, Managing Multiple Records, covers recipes to manage multiple records in a single page, ranging from editing parent and child records to managing a deep and wide hierarchy.

Chapter 6, Visualforce Charts, presents a series of recipes to create charts of increasing complexity, embed a chart into a standard Salesforce page, and add multiple charts to a single page in a similar style to a Salesforce dashboard.

Chapter 7, Enhancing the Client with JavaScript, shows how to use JavaScript to provide a variety of client-side enhancements, including confirmation of user actions, instant feedback on user inputs, and speeding up pages that access server-side data via remote methods.

Chapter 8, Force.com Sites, provides step-by-step instructions to configure a publicly accessible website styled with the Lightning Design System, allowing visitors to access the Salesforce records and extract boilerplate content to reusable templates.

Chapter 9, Visualforce in Salesforce1, demonstrates how Visualforce can be used to enhance the user experience on the Salesforce1 mobile device, including capturing the user’s location and attaching images when creating records.

Chapter 10, Troubleshooting, covers some common error scenarios and how to avoid them, along with tips to improve performance by reducing the size of the Visualforce viewstate and page load time in general.

What you need for this book

In order to build the recipes from this book, you will need an Enterprise, Unlimited or Developer (recommended) Edition of Salesforce, and System Administrator access. You will also need a supported browser, such as the latest version of Google Chrome, Mozilla Firefox, Apple Safari 8+, Internet Explorer 9+, or Microsoft Edge. Use the Setup menu to cut and paste the code samples rather than the developer console, as it may report visibility errors when the organization has a custom namespace.

Who this book is for

This book is intended for intermediate Visualforce developers who are familiar with the basics of Visualforce and Apex development on the Salesforce platform. An understanding of the basics of HTML, CSS and JavaScript is also useful for some more advanced recipes.

Sections

In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).

To give clear instructions on how to complete a recipe, we use these sections as follows:

Getting ready

This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There's more…

This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Once the payment reaches the state Complete the action poller will be disabled."

A block of code is set as follows:

<apex:column style="color:
   {!IF(AND(NOT(ISNULL(campaign.ActualCost)),
   campaign.ActualCost<=campaign.BudgetedCost),
  "lawngreen", "red")}" value="{!campaign.ActualCost}"/>

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Click on the New button."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book for which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows

  • Zipeg / iZip / UnRarX for Mac

  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Visualforce-Development-Cookbook-2e. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/VisualforceDevelopmentCookbook_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.