org.apache.cocoon.forms.formmodel
Class Output

java.lang.Object
  extended by org.apache.cocoon.forms.formmodel.AbstractWidget
      extended by org.apache.cocoon.forms.formmodel.Output
All Implemented Interfaces:
ValueChangedListenerEnabled, DataWidget, Widget, Locatable

public class Output
extends AbstractWidget
implements DataWidget, ValueChangedListenerEnabled

An Output widget can be used to show a non-editable value to the user. An Output widget is associated with a certain Datatype.

An Output widget is always valid and never required.

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

Field Summary
 
Fields inherited from class org.apache.cocoon.forms.formmodel.AbstractWidget
wasValid
 
Fields inherited from interface org.apache.cocoon.forms.formmodel.Widget
PATH_SEPARATOR
 
Constructor Summary
Output(OutputDefinition definition)
           
 
Method Summary
 void addValueChangedListener(ValueChangedListener listener)
           
 void broadcastEvent(WidgetEvent event)
          Broadcast an event previously queued by this widget to its event listeners.
protected  void generateItemSaxFragment(ContentHandler contentHandler, Locale locale)
          Generates nested additional content nested inside the main element for this widget which is generated by AbstractWidget.generateSaxFragment(ContentHandler, Locale) The implementation on the AbstractWidget level inserts no additional XML.
 Datatype getDatatype()
           
 WidgetDefinition getDefinition()
          Concrete subclasses should allow access to their underlaying Definition through this method.
 OutputDefinition getOutputDefinition()
           
 Object getValue()
          Get the value of a widget.
 String getXMLElementName()
          The XML element name used in AbstractWidget.generateSaxFragment(ContentHandler, Locale) to produce the wrapping element for all the XML-instance-content of this Widget.
 boolean hasValueChangedListeners()
           
 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 isValid()
          Return the current validation state.
 void readFromRequest(FormContext formContext)
          Lets this widget read its data from a request.
 void removeValueChangedListener(ValueChangedListener listener)
           
 void setValue(Object object)
          Sets the value of this widget.
 boolean validate()
          Validates this widget and returns the outcome.
 
Methods inherited from class org.apache.cocoon.forms.formmodel.AbstractWidget
addValidator, generateDisplayData, generateLabel, generateSaxFragment, getAttribute, getChild, getCombinedState, getForm, getFullName, getId, getLocation, getName, getParent, getRequestParameterName, getState, getWidget, getXMLElementAttributes, isRequired, lookupWidget, removeAttribute, removeValidator, setAttribute, setParent, setState, toString, widgetNameChanged
 
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
addValidator, generateLabel, generateSaxFragment, getAttribute, getCombinedState, getForm, getFullName, getId, getLocation, getName, getParent, getRequestParameterName, getState, getWidget, isRequired, lookupWidget, removeAttribute, removeValidator, setAttribute, setParent, setState
 

Constructor Detail

Output

public Output(OutputDefinition definition)
Method Detail

getDatatype

public Datatype getDatatype()
Specified by:
getDatatype in interface DataWidget

getDefinition

public WidgetDefinition getDefinition()
Description copied from class: AbstractWidget
Concrete subclasses should allow access to their underlaying Definition through this method. If subclasses decide to return null they should also organize own implementations of AbstractWidget.getId(), AbstractWidget.getLocation(), AbstractWidget.validate(), AbstractWidget.generateLabel(ContentHandler) and AbstractWidget.generateDisplayData(ContentHandler) to avoid NPE's.

Specified by:
getDefinition in interface Widget
Specified by:
getDefinition in class AbstractWidget
Returns:
the widgetDefinition from which this widget was instantiated. (See WidgetDefinition.createInstance())

getOutputDefinition

public OutputDefinition getOutputDefinition()

initialize

public void initialize()
Description copied from class: AbstractWidget
Called after widget's environment has been setup, to allow for any contextual initalization, such as looking up case widgets for union widgets.

Specified by:
initialize in interface Widget
Overrides:
initialize in class AbstractWidget

readFromRequest

public void readFromRequest(FormContext formContext)
Description copied from interface: Widget
Lets this widget read its data from a request. At this point the Widget may try to convert the request parameter to its native datatype (if it is not a string), but it should not yet generate any validation errors.

Specified by:
readFromRequest in interface Widget

validate

public boolean validate()
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
Overrides:
validate in class AbstractWidget
Returns:
true to indicate all validations were ok, false otherwise
See Also:
Widget.validate()

isValid

public boolean isValid()
Description copied from interface: Widget
Return the current validation state. This method delivers the same result as the last call to Widget.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.

Specified by:
isValid in interface Widget
Overrides:
isValid in class AbstractWidget
Returns:
The result of the last call to Widget.validate().
See Also:
Widget.isValid()

getXMLElementName

public String getXMLElementName()
Description copied from class: AbstractWidget
The XML element name used in AbstractWidget.generateSaxFragment(ContentHandler, Locale) to produce the wrapping element for all the XML-instance-content of this Widget.

Specified by:
getXMLElementName in class AbstractWidget
Returns:
"output"

generateItemSaxFragment

protected void generateItemSaxFragment(ContentHandler contentHandler,
                                       Locale locale)
                                throws SAXException
Description copied from class: AbstractWidget
Generates nested additional content nested inside the main element for this widget which is generated by AbstractWidget.generateSaxFragment(ContentHandler, Locale) The implementation on the AbstractWidget level inserts no additional XML. Subclasses need to override to insert widget specific content.

Overrides:
generateItemSaxFragment in class AbstractWidget
Parameters:
contentHandler - to send the SAX events to
locale - in which context potential content needs to be put.
Throws:
SAXException

getValue

public Object getValue()
Description copied from interface: Widget
Get the value of a 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.

Specified by:
getValue in interface Widget
Overrides:
getValue in class AbstractWidget
Returns:
the value of the widget.

setValue

public void setValue(Object object)
Description copied from interface: Widget
Sets the value of this 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.

Specified by:
setValue in interface Widget
Overrides:
setValue in class AbstractWidget
Parameters:
object - the new widget's value.

addValueChangedListener

public void addValueChangedListener(ValueChangedListener listener)
Specified by:
addValueChangedListener in interface ValueChangedListenerEnabled

removeValueChangedListener

public void removeValueChangedListener(ValueChangedListener listener)
Specified by:
removeValueChangedListener in interface ValueChangedListenerEnabled

hasValueChangedListeners

public boolean hasValueChangedListeners()
Specified by:
hasValueChangedListeners in interface ValueChangedListenerEnabled

broadcastEvent

public void broadcastEvent(WidgetEvent event)
Description copied from class: AbstractWidget
Broadcast an event previously queued by this widget to its event listeners. Abstract implementation throws a UnsupportedOperationException. Concrete subclass widgets need to override when supporting event broadcasting.

Specified by:
broadcastEvent in interface Widget
Overrides:
broadcastEvent in class AbstractWidget


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