Surfacing errors

When a form submission results in a rerender of a section rather than refreshing the entire Visualforce page, it is very easy to cause error messages from the controller to be swallowed rather than displayed to the user. In this situation, as far as the user is concerned, the form submission is broken; they click on a button and nothing on the page changes.

In this recipe we will create a Visualforce page to create an opportunity. When the user selects the account for the opportunity, the form will be submitted. The controller then retrieves the account record so that additional fields on the page may be populated. If the opportunity name is not defined, the form submission will fail and an error message will be displayed to the ...

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.