org.apache.cocoon.forms.formmodel
Class AbstractWidgetDefinition

java.lang.Object
  extended byorg.apache.cocoon.forms.formmodel.AbstractWidgetDefinition
All Implemented Interfaces:
Locatable, WidgetDefinition
Direct Known Subclasses:
AbstractContainerDefinition, AbstractDatatypeWidgetDefinition, ActionDefinition, BooleanFieldDefinition, ImageMapDefinition, MessagesDefinition, NewDefinition, TreeDefinition, UploadDefinition

public abstract class AbstractWidgetDefinition
extends Object
implements WidgetDefinition

Provides functionality that is common across many WidgetDefinition implementations.

Version:
$Id: AbstractWidgetDefinition.java 326838 2005-10-20 06:26:53Z sylvain $

Field Summary
protected  CreateListener createListener
           
protected  WidgetDefinition parent
           
 
Constructor Summary
AbstractWidgetDefinition()
           
 
Method Summary
protected  void addCreateListener(CreateListener listener)
           
 void addValidator(WidgetValidator validator)
           
 void checkCompleteness()
          Checks if this definition is complete or not.
protected  void checkMutable()
          Check that this definition is mutable, i.e. is in setup phase.
protected  void copyMap(Map dest, Map src)
          helper to copy a map
 void fireCreateEvent(CreateEvent event)
           
 void generateDisplayData(ContentHandler contentHandler)
          Generates SAX events for display data.
 void generateDisplayData(String name, ContentHandler contentHandler)
          Generates SAX events for named display data.
 void generateLabel(ContentHandler contentHandler)
          Generates SAX events for the label of this widget.
 Object getAttribute(String name)
          Gets an attribute that has been defined on the widget's definition.
 FormDefinition getFormDefinition()
          Gets the FormDefinition.
 String getId()
          Gets id of this widget definition.
 Location getLocation()
          Gets source location of this widget definition.
 WidgetDefinition getParent()
          Gets the parent of this definition.
 WidgetState getState()
           
 void initializeFrom(WidgetDefinition definition)
          initialize this definition with the other, sort of like a copy constructor
 void makeImmutable()
          Locks this definition so that it becomes immutable.
protected  void setAttributes(Map attributes)
           
 void setDisplayData(Map displayData)
          Sets the various display data for this widget.
protected  void setId(String id)
           
 void setLocation(Location location)
           
 void setParent(WidgetDefinition definition)
          Sets the parent of this definition
 void setState(WidgetState state)
           
 boolean validate(Widget widget)
          Validate a widget using the validators that were defined in its definition.
 void widgetCreated(Widget widget)
           
 
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.forms.formmodel.WidgetDefinition
createInstance
 

Field Detail

parent

protected WidgetDefinition parent

createListener

protected CreateListener createListener
Constructor Detail

AbstractWidgetDefinition

public AbstractWidgetDefinition()
Method Detail

getFormDefinition

public FormDefinition getFormDefinition()
Description copied from interface: WidgetDefinition
Gets the FormDefinition.

Specified by:
getFormDefinition in interface WidgetDefinition

initializeFrom

public void initializeFrom(WidgetDefinition definition)
                    throws Exception
initialize this definition with the other, sort of like a copy constructor

Specified by:
initializeFrom in interface WidgetDefinition
Throws:
Exception

copyMap

protected void copyMap(Map dest,
                       Map src)
helper to copy a map

Parameters:
dest - destination map
src - source map

checkCompleteness

public void checkCompleteness()
                       throws IncompletenessException
Checks if this definition is complete or not.

Specified by:
checkCompleteness in interface WidgetDefinition
Throws:
IncompletenessException

makeImmutable

public void makeImmutable()
Locks this definition so that it becomes immutable.


checkMutable

protected void checkMutable()
Check that this definition is mutable, i.e. is in setup phase. If not, throw an exception.


setParent

public void setParent(WidgetDefinition definition)
Sets the parent of this definition

Specified by:
setParent in interface WidgetDefinition

getParent

public WidgetDefinition getParent()
Gets the parent of this definition. This method returns null for the root definition.


getState

public WidgetState getState()

setState

public void setState(WidgetState state)

setLocation

public void setLocation(Location location)

getLocation

public Location getLocation()
Description copied from interface: WidgetDefinition
Gets source location of this widget definition.

Specified by:
getLocation in interface WidgetDefinition

getId

public String getId()
Description copied from interface: WidgetDefinition
Gets id of this widget definition.

Specified by:
getId in interface WidgetDefinition

setId

protected void setId(String id)

setAttributes

protected void setAttributes(Map attributes)

getAttribute

public Object getAttribute(String name)
Description copied from interface: WidgetDefinition
Gets an attribute that has been defined on the widget's definition.

Specified by:
getAttribute in interface WidgetDefinition
Parameters:
name - the attribute name
Returns:
the attribute value, or null if it doesn't exist

addCreateListener

protected void addCreateListener(CreateListener listener)

widgetCreated

public void widgetCreated(Widget widget)

fireCreateEvent

public void fireCreateEvent(CreateEvent event)

generateLabel

public void generateLabel(ContentHandler contentHandler)
                   throws SAXException
Description copied from interface: WidgetDefinition
Generates SAX events for the label of this widget.

Specified by:
generateLabel in interface WidgetDefinition
Throws:
SAXException

setDisplayData

public void setDisplayData(Map displayData)
Sets the various display data for this widget. This includes the label, hint and help. They must all be objects implementing the XMLizable interface. This approach allows to have mixed content in these data.

Parameters:
displayData - an association of {name, sax fragment}

addValidator

public void addValidator(WidgetValidator validator)

generateDisplayData

public void generateDisplayData(String name,
                                ContentHandler contentHandler)
                         throws SAXException
Description copied from interface: WidgetDefinition
Generates SAX events for named display data.

Specified by:
generateDisplayData in interface WidgetDefinition
Throws:
SAXException

generateDisplayData

public void generateDisplayData(ContentHandler contentHandler)
                         throws SAXException
Description copied from interface: WidgetDefinition
Generates SAX events for display data.

Specified by:
generateDisplayData in interface WidgetDefinition
Throws:
SAXException

validate

public boolean validate(Widget widget)
Description copied from interface: WidgetDefinition
Validate a widget using the validators that were defined in its definition. If validation fails, the validator has set a validation error on the widget or one of its children.

Specified by:
validate in interface WidgetDefinition
Parameters:
widget - the widget
Returns:
true if validation was successful.


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.