|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.cocoon.forms.formmodel.AbstractWidget
public abstract class AbstractWidget
Abstract base class for Widget implementations. Provides functionality common to many widgets.
| Field Summary | |
|---|---|
protected boolean |
wasValid
The result of the last call to validate(). |
| Fields inherited from interface org.apache.cocoon.forms.formmodel.Widget |
|---|
PATH_SEPARATOR |
| Constructor Summary | |
|---|---|
protected |
AbstractWidget(AbstractWidgetDefinition definition)
|
| Method Summary | |
|---|---|
void |
addValidator(WidgetValidator validator)
Add a validator to this widget instance. |
void |
broadcastEvent(WidgetEvent event)
Broadcast an event previously queued by this widget to its event listeners. |
protected void |
generateDisplayData(ContentHandler contentHandler)
Delegates to the getDefinition() of this widget to generate a common
set of 'display' data. |
protected void |
generateItemSaxFragment(ContentHandler contentHandler,
Locale locale)
Generates nested additional content nested inside the main element for this widget which is generated by generateSaxFragment(ContentHandler, Locale)
The implementation on the AbstractWidget level inserts no additional XML. |
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. |
Object |
getAttribute(String name)
Retrieves an attribute on this widget. |
protected Widget |
getChild(String id)
Concrete widgets that contain actual child widgets should override to return the actual child-widget. |
WidgetState |
getCombinedState()
Get the widget's combined state, which is the strictest of its own state and parent state. |
abstract WidgetDefinition |
getDefinition()
Concrete subclasses should allow access to their underlaying Definition through this method. |
Form |
getForm()
|
String |
getFullName()
|
String |
getId()
Gets the id of this widget. |
Location |
getLocation()
Get the location of this object |
String |
getName()
|
Widget |
getParent()
|
String |
getRequestParameterName()
|
WidgetState |
getState()
Get the widget's own state. |
Object |
getValue()
Get the value of a widget. |
Widget |
getWidget(String id)
|
protected AttributesImpl |
getXMLElementAttributes()
The XML attributes used in generateSaxFragment(ContentHandler, Locale)
to be placed on the wrapping element for all the XML-instance-content of this Widget. |
protected abstract String |
getXMLElementName()
The XML element name used in generateSaxFragment(ContentHandler, Locale)
to produce the wrapping element for all the XML-instance-content of this Widget. |
void |
initialize()
Called after widget's environment has been setup, to allow for any contextual initalization, such as looking up case widgets for union widgets. |
boolean |
isRequired()
|
boolean |
isValid()
Return the current validation state. |
Widget |
lookupWidget(String path)
Finds a widget relative to this one based on a path-like string (/-delimted) into the widget-tree structure. |
void |
removeAttribute(String name)
Removes the named attribute from this widget. |
boolean |
removeValidator(WidgetValidator validator)
Remove a validator from this widget instance |
void |
setAttribute(String name,
Object value)
Sets an attribute on this widget. |
void |
setParent(Widget widget)
Sets the parent-widget of this widget. |
void |
setState(WidgetState state)
Set the widget's own state. |
void |
setValue(Object object)
Sets the value of this widget. |
String |
toString()
|
boolean |
validate()
Validates this widget and returns the outcome. |
protected void |
widgetNameChanged()
Should be called when a widget's own name has changed, in order to clear internal caches used to compute request parameters. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.apache.cocoon.forms.formmodel.Widget |
|---|
readFromRequest |
| Field Detail |
|---|
protected boolean wasValid
validate().
| Constructor Detail |
|---|
protected AbstractWidget(AbstractWidgetDefinition definition)
| Method Detail |
|---|
public void initialize()
initialize in interface Widgetpublic String getId()
getId in interface Widgetnull
Top-level container widgets (like 'form') should return ""public String getName()
getName in interface Widgetnull
Top-level container widgets (like 'form') should return ""public abstract WidgetDefinition getDefinition()
null they should also organize
own implementations of getId(), getLocation(),
validate(), generateLabel(ContentHandler) and
generateDisplayData(ContentHandler) to avoid NPE's.
getDefinition in interface WidgetWidgetDefinition.createInstance())public Location getLocation()
Locatable
getLocation in interface WidgetgetLocation in interface Locatablepublic final Widget getParent()
getParent in interface Widgetpublic void setParent(Widget widget)
setParent in interface Widgetwidget - the parent-widget of this one.
IllegalStateException - when the parent had already been set.public Form getForm()
getForm in interface Widgetpublic WidgetState getState()
Widget
getState in interface WidgetWidget.getCombinedState()public void setState(WidgetState state)
Widget
setState in interface Widgetstate - the new wiget statepublic WidgetState getCombinedState()
Widget
getCombinedState in interface WidgetWidgetState.strictest(WidgetState, WidgetState)protected void widgetNameChanged()
public String getFullName()
getFullName in interface Widgetpublic String getRequestParameterName()
getRequestParameterName in interface Widgetpublic Widget lookupWidget(String path)
Widget
lookupWidget in interface Widgetnull if allong the traversal
of the path an invalid section was encountered.protected Widget getChild(String id)
id - of the child-widget
null if not overriden.public Widget getWidget(String id)
getWidget in interface Widgetpublic Object getValue()
Widget
Not all widgets do have a value (notably ContainerWidgets,
but this method is provided here as a convenience to ease writing and avoiding casts.
getValue in interface Widgetpublic void setValue(Object object)
Widget
Not all widgets do have a value (notably ContainerWidgets,
but this method is provided here as a convenience to ease writing and avoiding casts.
setValue in interface Widgetobject - the new widget's value.public boolean isRequired()
isRequired in interface WidgetWidget.getValue(),
for some widgets this may not make sense, those should return false here.public void broadcastEvent(WidgetEvent event)
UnsupportedOperationException.
Concrete subclass widgets need to override when supporting event broadcasting.
broadcastEvent in interface Widgetpublic void addValidator(WidgetValidator validator)
addValidator in interface Widgetvalidator - public boolean removeValidator(WidgetValidator validator)
removeValidator in interface Widgetvalidator -
true if the validator was found.public boolean validate()
WidgetWidget.generateSaxFragment(ContentHandler, Locale) method.
validate in interface Widgettrue to indicate all validations were ok,
false otherwiseWidget.validate()public boolean isValid()
WidgetWidget.validate().
The validation process is not started again. If the value of this widget has
changed since the latest call to Widget.validate(), the result of this method
is out of date.
isValid in interface WidgetWidget.validate().Widget.isValid()
public void generateLabel(ContentHandler contentHandler)
throws SAXException
getDefinition() to generate the 'label' part of
the display-data of this widget.
Subclasses should override if the getDefinition can return null
to avoid NPE's
generateLabel in interface WidgetcontentHandler -
SAXException
protected void generateItemSaxFragment(ContentHandler contentHandler,
Locale locale)
throws SAXException
generateSaxFragment(ContentHandler, Locale)
The implementation on the AbstractWidget level inserts no additional XML.
Subclasses need to override to insert widget specific content.
contentHandler - to send the SAX events tolocale - in which context potential content needs to be put.
SAXExceptionprotected abstract String getXMLElementName()
generateSaxFragment(ContentHandler, Locale)
to produce the wrapping element for all the XML-instance-content of this Widget.
protected AttributesImpl getXMLElementAttributes()
generateSaxFragment(ContentHandler, Locale)
to be placed on the wrapping element for all the XML-instance-content of this Widget.
This automatically adds @id=getRequestParameterName() to that element.
Concrete subclasses should call super.getXMLElementAttributes and possibly
add additional attributes.
Note: the @id is not added for those widgets who's getId() returns null
(e.g. top-level container widgets like 'form'). The contract of returning a non-null
AttributesImpl is however maintained.
protected void generateDisplayData(ContentHandler contentHandler)
throws SAXException
getDefinition() of this widget to generate a common
set of 'display' data. (i.e. help, label, hint,...)
Subclasses should override if the getDefinition can return null
to avoid NPE's.
contentHandler - where to send the SAX events to.
SAXExceptionWidgetDefinition.generateDisplayData(ContentHandler)
public void generateSaxFragment(ContentHandler contentHandler,
Locale locale)
throws SAXException
getXMLElementName()) with attributes
(provided by getXMLElementAttributes() around anything injected
in by both generateDisplayData(ContentHandler) and
generateItemSaxFragment(ContentHandler, Locale).
<fi:getXMLElementName()getXMLElementAttributes()>generateDisplayData(ContentHandler)(i.e. help, label, ...)generateItemSaxFragment(ContentHandler, Locale)</fi:getXMLElementName()>
generateSaxFragment in interface WidgetcontentHandler - to send the SAX events tolocale - in which context potential content needs to be put.
SAXExceptionpublic Object getAttribute(String name)
Widget
getAttribute in interface Widgetname - of the attribute to lookup
null if none was found with that name.
public void setAttribute(String name,
Object value)
Widget
setAttribute in interface Widgetpublic void removeAttribute(String name)
Widget
removeAttribute in interface Widgetname - of the attributepublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||