Skip navigation links

Package net.sf.jguiraffe.transform

The transform package contains interfaces and classes for transforming and validating data.

See: Description

Package net.sf.jguiraffe.transform Description

The transform package contains interfaces and classes for transforming and validating data.

Form processing always includes the validation of the data entered by the user. If input is valid, it has to be copied into the application's data model. This step may require the conversion of data into some other types to conform with the types used within the model.

This package deals with both of these use cases. It defines the Transformer interface for data conversion and the Validator interface for validation. There are also fully functional implementations of these interfaces for the most common use cases.

It is also possible to implement custom transformers and validators. The interfaces are straight forward and easy to implement. When defining a form using the GUI builder the transformers and validators to use can be specified.

The Form class representing an input form in this framework implements some functionality for processing data entered by the user. It first invokes all registered validators on the input components. Only if this step was successful, the transformers are invoked. This causes the data entered by the user to be converted as necessary and copied into the bean associated with the form.

If a validator finds out that an input field contains invalid data, it returns a ValidationResult object with one or more error messages. Each message consists of a key that is specific for this kind of error message and a text to be displayed to the user. This text can contain further information about the error and how to resolve it (e.g. something like "This field must contain a number less than 100"; note that dynamic data depending on the validator's configuration is automatically added). In the documentation of each validator class the possible error messages are listed.

In addition to the key and the message a ValidationResult object also contains a level. The default level is ERROR indicating the input is actually invalid. It is also possible to use the level WARNING, which means that the input will be accepted, but may cause problems. Whether a validator produces error or warning messages can be configured with properties in the TransformerContext. For more information refer to the documentation of DefaultValidationMessageHandler.

Changing the error messages for certain or all validators is an often required use case. Per default error messages are obtained from the resource manager: the key of the error message is used as resource ID, as resource group the reserved name "validators" is used. The framework is shipped with default error messages in a couple of supported languages. If a specific language you need is not supported, you can add your own bundle for this language. To override specific validation error messages there are the following options:

$Id: package.html 205 2012-01-29 18:29:57Z oheger $

Skip navigation links

Copyright © 2016 The JGUIraffe Team. All rights reserved.