org.apache.cocoon.woody.formmodel
Class AbstractWidget

java.lang.Object
  extended by org.apache.cocoon.woody.formmodel.AbstractWidget
All Implemented Interfaces:
Widget
Direct Known Subclasses:
AbstractContainerWidget, Action, BooleanField, Field, Messages, MultiValueField, Output, Repeater, Upload

public abstract class AbstractWidget
extends Object
implements Widget

Abstract base class for Widget implementations. Provides functionality common to many widgets.

Version:
$Id: AbstractWidget.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Field Summary
protected  AbstractWidgetDefinition definition
           
 
Constructor Summary
AbstractWidget()
           
 
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.
 void generateItemSaxFragment(ContentHandler contentHandler, Locale locale)
           
 void generateLabel(ContentHandler contentHandler)
          Generates SAX events for the label of this widget.
 void generateSaxFragment(ContentHandler contentHandler, Locale locale, String element, WidgetDefinition definition)
           
 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()
          Gets 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.
 boolean removeValidator(WidgetValidator validator)
          Remove a validator from this widget instance
protected  void setDefinition(AbstractWidgetDefinition definition)
          Sets the definition of this widget.
protected  void setLocation(String location)
          Sets the source location of this widget.
 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 context)
          Validates this widget and returns the outcome.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.woody.formmodel.Widget
generateSaxFragment, readFromRequest
 

Field Detail

definition

protected AbstractWidgetDefinition definition
Constructor Detail

AbstractWidget

public AbstractWidget()
Method Detail

setDefinition

protected void setDefinition(AbstractWidgetDefinition definition)
Sets the definition of this widget.


getId

public String getId()
Gets the id of this widget.

Specified by:
getId in interface Widget

setLocation

protected void setLocation(String location)
Sets the source location of this widget.


getLocation

public String getLocation()
Gets the source location of this widget.

Specified by:
getLocation in interface Widget

getParent

public Widget getParent()
Description copied from interface: Widget
Gets the parent of this widget. If this widget is the root widget, this method returns null.

Specified by:
getParent in interface Widget

setParent

public void setParent(Widget widget)
Description copied from interface: Widget
This method is called on a widget when it is added to a container. You shouldn't call this method unless youre implementing a widget yourself (in which case it should be called when a widget is added as child of your widget).

Specified by:
setParent in interface Widget

getForm

public Form getForm()
Description copied from interface: Widget
Get the Form to which this widget belongs. The form is the top-most ancestor of the widget.

Specified by:
getForm in interface Widget

getNamespace

public String getNamespace()
Description copied from interface: Widget
Gets the namespace of this widget. The combination of a widget's namespace with its id (see Widget.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.

Specified by:
getNamespace in interface Widget

getFullyQualifiedId

public String getFullyQualifiedId()
Description copied from interface: Widget
Returns the id prefixed with the namespace, this name should be unique accross all widgets on the form.

Specified by:
getFullyQualifiedId in interface Widget

getValue

public Object getValue()
Description copied from interface: Widget
Returns the value of the widget. For some widgets (notably ContainerWidgets) this may not make sense, those should then simply return null here.

Specified by:
getValue in interface Widget

setValue

public void setValue(Object object)
Description copied from interface: Widget
Sets the value of this widget to the given object. Some widgets may not support this method, those should throw an runtime exception if you try to set their value anyway.

Specified by:
setValue in interface Widget

isRequired

public boolean isRequired()
Description copied from interface: Widget
Returns wether this widget is required to be filled in. As with Widget.getValue(), for some widgets this may not make sense, those should return false here.

Specified by:
isRequired in interface Widget

getWidget

public Widget getWidget(String id)
Description copied from interface: Widget
Gets the child widget of this widget with the given id, or null if there isn't such a child.

Specified by:
getWidget in interface Widget

broadcastEvent

public void broadcastEvent(WidgetEvent event)
Description copied from interface: Widget
Broadcast an event previously queued by this widget to its event listeners.

Specified by:
broadcastEvent in interface Widget

addValidator

public void addValidator(WidgetValidator validator)
Add a validator to this widget instance.

Parameters:
validator -

removeValidator

public boolean removeValidator(WidgetValidator validator)
Remove a validator from this widget instance

Parameters:
validator -
Returns:
true if the validator was found.

validate

public boolean validate(FormContext context)
Description copied from interface: Widget
Validates this widget and returns the outcome. Possible error messages are remembered by the widget itself and will be part of the XML produced by this widget in its Widget.generateSaxFragment(ContentHandler, Locale) method.

Specified by:
validate in interface Widget

generateLabel

public void generateLabel(ContentHandler contentHandler)
                   throws SAXException
Description copied from interface: Widget
Generates SAX events for the label of this widget. The label will not be wrapped inside another element.

Specified by:
generateLabel in interface Widget
Throws:
SAXException

generateItemSaxFragment

public void generateItemSaxFragment(ContentHandler contentHandler,
                                    Locale locale)
                             throws SAXException
Throws:
SAXException

generateSaxFragment

public void generateSaxFragment(ContentHandler contentHandler,
                                Locale locale,
                                String element,
                                WidgetDefinition definition)
                         throws SAXException
Throws:
SAXException


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.