dWebSpec Dictionary
CONTEXT: descriptors->element->type-cat-message




All Details Standard Only Platform Only
Structured Web info and helpTechnologies
 Home Page
 Product Page
 Download Page
 Feedback
Javascript Tree Menu

Results for:

 element.type-cat-message 
Prev  Topic  Next

message

The message category covers the messages element of dWebSpec.

This category captures the various way platforms would capture messages and display them on the page view.

The messages element provides messages for the page or enclosing form; whereas the message element provides messages for individual elements.

Some of the features provided by platforms are, Categorization of messages, Standardized error messages, Field error messages, and internationalization. These are expanded upon below.

Categorization of messages

This involves means of grouping the errors into categories, which would allow showing the appropriate messages, as relevant or per user customization. It also allow applying different styles to the messages, for instance red fonts for errors, and green for informational.

Standardized error messages

A scheme is usually provided to define a list of standardize messages. These messages would allow some level of customization, by including tokens or place holder that could be replaced with predetermined or ad-hoc strings.

There would also be standard means to add custom messages at runtime.

Field Errors

The standardized errors could be leverage to allow passing the field label as parameter to make it appear field specific.

The validator would allow for message specifications. The syntax is as follow; it should be noted that the variables required vary for the different validations.

Validator:message,variable1,variable2,...

Example being: MaxLengthValidator:"Text must be less than 24 characters",25

Specification of element validation messages in dWebSpec.

Internationalization

All the messages discussed above, should have possibility of being presented as simply string or externalized strings for internationalization.

 Seam  

Categorization of messages

JSF provides for the following categories of messages, error, fatal, info, and warn.

Standardized error messages

The JSF API includes series of constants that define a set of default messages. Examples of such constants and messages are shown below.

javax.faces.component.UIInput.REQUIRED=Validation Error: Value is required.
javax.faces.component.UIInput.CONVERSION=Conversion error during model data update.
javax.faces.component.UISelectOne.INVALID=Validation Error: Value is not valid.
javax.faces.component.UISelectMany.INVALID=Validation Error: Value is not valid.

These messages could be overridden by defining them in resource bundle that is explicitly loaded on the page, rather that using the default.

It is the accumulated messages that are shown with the message components. Custom errors could be added in the backing bean using the following syntax.

FacesMessage message = new FacesMessage("Email address is required.");
facesContext.addMessage(clientId,message);

Field Errors

The field errors are handled as part of standardized error scheme. JSF would display errors for a component. The errors might appear a little unfriendly, like the following.

j_id23:j_id24:0:TxtEmail: Validation Error: Value is required

This is why it is important to attach a label component to input components involved in validations. This message could be made user friendly by attaching a label component to the input element. There are situation that this is not practical; examples are input elements in rows or grid data. The input components have ?label? attribute that could be used in such cases.

Whenever custom messages are specified, the following component attributes could be used to implement them.

  • converterMessage
  • validatorMessage
  • requiredMessage

UIMessage and UIMessages JSF families

messages(field) h:message
messages html:messages/html:errors
Prev Next