|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Widget
Interface to be implemented by Widgets. In Woody, a form consists of a number of widgets. Each widget:
getId()
.getWidget(String)
, and can have a parent (see getParent()
.getValue()
.readFromRequest(FormContext)
.validate(FormContext)
.Because widgets can have children, the widgets form a widget tree, with its root
being the Form
widget.
A widget can have only a value, or only child widgets, or can have both a value and child widgets, or can have neither. This all depends on the widget implementation.
When a request is submitted, first the readFromRequest(FormContext)
method of all widgets
will be called so that they can read their value(s). Next, the validate(FormContext)
method will
be called. Doing this in two steps allows the validation to compare values between widgets.
See also the method Form.process(FormContext)
.
A Widget is created by calling the createInstance method on the a
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.
Method Summary | |
---|---|
void |
broadcastEvent(WidgetEvent event)
Broadcast an event previously queued by this widget to its event listeners. |
void |
generateLabel(ContentHandler contentHandler)
Generates SAX events for the label of this widget. |
void |
generateSaxFragment(ContentHandler contentHandler,
Locale locale)
Generates an XML representation of this widget. |
Form |
getForm()
Get the Form to which this widget belongs. |
String |
getFullyQualifiedId()
Returns the id prefixed with the namespace, this name should be unique accross all widgets on the form. |
String |
getId()
Returns the id of this widget. |
String |
getLocation()
Gets the source location of this widget. |
String |
getNamespace()
Gets the namespace of this widget. |
Widget |
getParent()
Gets the parent of this widget. |
Object |
getValue()
Returns the value of the widget. |
Widget |
getWidget(String id)
Gets the child widget of this widget with the given id, or null if there isn't such a child. |
boolean |
isRequired()
Returns wether this widget is required to be filled in. |
void |
readFromRequest(FormContext formContext)
Lets this widget read its data from a request. |
void |
setParent(Widget widget)
This method is called on a widget when it is added to a container. |
void |
setValue(Object object)
Sets the value of this widget to the given object. |
boolean |
validate(FormContext formContext)
Validates this widget and returns the outcome. |
Method Detail |
---|
String getLocation()
String getId()
Widget getParent()
void setParent(Widget widget)
Form getForm()
Form
to which this widget belongs. The form is the top-most ancestor
of the widget.
String getNamespace()
getId()
gives the widget a form-wide unique name.
In practice, the namespace consists of the id's of the widget's parent widgets,
separated by dots.
String getFullyQualifiedId()
void readFromRequest(FormContext formContext)
boolean validate(FormContext formContext)
generateSaxFragment(ContentHandler, Locale)
method.
void generateSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException
SAXException
void generateLabel(ContentHandler contentHandler) throws SAXException
SAXException
Object getValue()
void setValue(Object object)
boolean isRequired()
getValue()
, for some
widgets this may not make sense, those should return false here.
Widget getWidget(String id)
void broadcastEvent(WidgetEvent event)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |