Runtime components : Core components : Typed data : Concepts : Validators : Data element validation
  
Data element validation
Data elements provide a protocol for validating objects based on their concrete descriptor definitions. These definitions include element state and validator properties. The validation process, ultimately performed by the concrete validator implementation, fires an exception when the validation process ends with errors. Element state provides a way for you to define status flags such as isMandatory, isOmitted, isHidden, isReadOnly, and isDisabled. The ElementState interface defines an API to get and set these flags. The toolkit provides a default implementation for the ElementState interface: the DSEElementState class. This class defines a mask of 32 bits in which the toolkit reserves positions 15 to 4 for internal use. The other positions of the 32 bit mask (bits in positions 3 to 0 and 31 to 16) are available to use as status flags for applications that require them. You can replace this implementation if necessary.
The validation process first uses the state attribute of the data element instance to validate the passed data. For example, a null value is not valid if the state attribute of a data field instance has an active mandatory flag. Once the data passes the state validation, the descriptor validates the data according to the type's business rules. If the data fails validation, the process updates the ErrorInfo object of the data element with the error information that the solution may later require. This error information forms a message with a static part and a dynamic part separated by delimiters. For example, the solution may use JSP code to render an HTML page that displays localized error messages for the errors that occurred while validating the incoming data.
The ErrorInfo class extends the com.ibm.btt.base.Hashtable class and maintains information about each error detected while validating a typed data field. This information consists of a key-value pair in which the key is a String that identifies a detected error and the value is a String that gives a default detailed explanation of the error. To localize this information, each supported locale has a types.properties and a typesext.properties file that contains localized error messages (see NLS).
Go up to
Validators