org.apache.cocoon.forms.formmodel
Class Action

java.lang.Object
  extended by org.apache.cocoon.forms.formmodel.AbstractWidget
      extended by org.apache.cocoon.forms.formmodel.Action
All Implemented Interfaces:
ActionListenerEnabled, Widget, Locatable
Direct Known Subclasses:
RepeaterAction, RowAction, Submit

public class Action
extends AbstractWidget
implements ActionListenerEnabled

An Action widget. An Action widget can cause an ActionEvent to be triggered on the server side, which will be handled by either the event handlers defined in the form definition, and/or by the FormHandler registered with the form, if any. An Action widget can e.g. be rendered as a button, or as a hidden field which gets its value set by javascript. The Action widget will generate its associated ActionEvent when a requestparameter is present with as name the id of this Action widget, and as value a non-empty value.

Version:
$Id: Action.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
Action(ActionDefinition definition)
           
 
Method Summary
 void addActionListener(ActionListener listener)
          Adds a ActionListener to this widget instance.
 void broadcastEvent(WidgetEvent event)
          Broadcast an event previously queued by this widget to its event listeners.
 WidgetDefinition getDefinition()
          Concrete subclasses should allow access to their underlaying Definition through this method.
 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.
protected  void handleActivate()
          Handle the fact that this action was activated.
 boolean isValid()
          Return the current validation state.
 void performAction()
          Performs all actions and calls on-action listeners attached to this object.
 void readFromRequest(FormContext formContext)
          Lets this widget read its data from a request.
 void removeActionListener(ActionListener listener)
           
 boolean validate()
          Always return true (an action has no validation)
TODO is there a use case for actions having validators?
 
Methods inherited from class org.apache.cocoon.forms.formmodel.AbstractWidget
addValidator, generateDisplayData, generateItemSaxFragment, generateLabel, generateSaxFragment, getAttribute, getChild, getCombinedState, getForm, getFullName, getId, getLocation, getName, getParent, getRequestParameterName, getState, getValue, getWidget, getXMLElementAttributes, initialize, isRequired, lookupWidget, removeAttribute, removeValidator, setAttribute, setParent, setState, setValue, toString, widgetNameChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Action

public Action(ActionDefinition definition)
Method Detail

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())

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

performAction

public void performAction()
Performs all actions and calls on-action listeners attached to this object. Note that this does not register this object as the submit widget and doesn't stop form processing.


handleActivate

protected void handleActivate()
Handle the fact that this action was activated. The default here is to perform any action associated to this object, end the current form processing and redisplay the form.

See Also:
performAction()

validate

public boolean validate()
Always return true (an action has no validation)
TODO is there a use case for actions having validators?

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:
"action"

addActionListener

public void addActionListener(ActionListener listener)
Adds a ActionListener to this widget instance. Listeners defined on the widget instance will be executed in addtion to any listeners that might have been defined in the widget definition.

Specified by:
addActionListener in interface ActionListenerEnabled

removeActionListener

public void removeActionListener(ActionListener listener)
Specified by:
removeActionListener in interface ActionListenerEnabled

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.