org.apache.cocoon.forms.formmodel
Class AbstractWidgetDefinition

java.lang.Object
  extended by org.apache.cocoon.forms.formmodel.AbstractWidgetDefinition
All Implemented Interfaces:
WidgetDefinition, Locatable
Direct Known Subclasses:
AbstractContainerDefinition, AbstractDatatypeWidgetDefinition, ActionDefinition, BooleanFieldDefinition, GoogleMapDefinition, 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.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Field Summary
protected  CreateListener createListener
           
protected  Library enclosingLibrary
           
protected  WidgetDefinition parent
           
 
Constructor Summary
AbstractWidgetDefinition()
           
 
Method Summary
 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.
 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.
 Library getEnclosingLibrary()
          Gets the Library object containing this 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.
 void setAttributes(Map attributes)
           
 void setDisplayData(Map displayData)
          Sets the various display data for this widget.
 void setEnclosingLibrary(Library library)
          Sets the Library object containing this definition (should only be used by Library itself!)
 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

enclosingLibrary

protected Library enclosingLibrary

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

getEnclosingLibrary

public Library getEnclosingLibrary()
Description copied from interface: WidgetDefinition
Gets the Library object containing this definition

Specified by:
getEnclosingLibrary in interface WidgetDefinition

setEnclosingLibrary

public void setEnclosingLibrary(Library library)
Description copied from interface: WidgetDefinition
Sets the Library object containing this definition (should only be used by Library itself!)

Specified by:
setEnclosingLibrary 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

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
Specified by:
getLocation in interface Locatable
Returns:
the location

getId

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

Specified by:
getId in interface WidgetDefinition

setId

public void setId(String id)

setAttributes

public 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

public 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-2010 The Apache Software Foundation. All Rights Reserved.