Adding error messages to non-field inputs

In the previous recipe, Adding error messages to field inputs, the platform took care of positioning the error message based on whether the field had any errors associated with it. Visualforce automatically provides this functionality for <apex:inputField /> components, but if a different input component is used, such as <apex:inputText /> or <apex:selectList />, there is no equivalent functionality.

In this recipe, we will create a Visualforce page to allow a user to create or edit a contact record. The contact standard controller and a controller extension manage the page. The ID of the account that the contact is associated with is entered via an <apex:selectList /> component, which is bound to a controller ...

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.