Tools for building business domain Model Objects (MOs).

The important things about Model Objects in WEB4J are :

Restrictions on Model Objects

These are the restrictions on Model Objects in WEB4J :

These items can be added to Model Objects, if desired, but they are never used by WEB4J :

Validation

Validation in Model Objects is always in the constructor, and can usually be implemented using the {@link hirondelle.web4j.model.Check} class, which provides commonly needed implementions of the {@link hirondelle.web4j.model.Validator} interface. When a problem occurs, an error message is added to {@link hirondelle.web4j.model.ModelCtorException}, for later presentation to the user.

Object Methods

It is highly recommended that all Model Objects override equals, hashCode, and toString. ({@link hirondelle.web4j.model.ModelUtil} can help you implement these methods.)

Building Model Objects

In general, there are two sources for the data attached to Model Objects : manual entry by the end user, and the database. It is interesting that both of these sources should be treated as unreliable. Incoming HTTP request parameters are not constrained, and must always be aggressively validated on the server. Databases are independent servers, and cannot be assumed to be 'owned' by the application. Other applications and processes can interact with the data as well. Thus, an application cannot, in general, make any assumptions regarding the content of the database.

Thus, a Model Object must allow for all possible input when creating objects from both these sources.

WEB4J has two main tools for this task :

Both of these tools are simple to use because they use effective ordering conventions for data.