Interface to be implemented by Widgets. In CForms, a form consists of a number of widgets. Each widget:
- has an id, unique within its parent context widget. See {@link #getId()}.
- can have a parent (see {@link #getParent()}.
- can hold a value (which can be any kind of object). See {@link #getValue()}.
- can read its value from a request object (and convert it from a string to its native type). See {@link #readFromRequest(FormContext)}.
- can validate itself. See {@link #validate()}.
- can generate an XML representation of itself.
When a request is submitted, first the {@link #readFromRequest(FormContext)} method of all widgetswill be called so that they can read their value(s). Next, the {@link #validate()} method willbe called. Doing this in two steps allows the validation to compare values between widgets. See also the method {@link Form#process(FormContext)}.
A Widget is created by calling the createInstance method on the a {@link WidgetDefinition}. A Widget holds all the data that is specific for a certain use of the widget (its value, validationerrors, ...), while the WidgetDefinition holds the data that is static accross all widgets. This keeps the Widgets small and light to create. This mechanism is similar to classes and objects in Java.
@version $Id: Widget.java 155210 2005-02-24 17:02:09Z sylvain $