org.apache.cocoon.woody.formmodel
Class Form

java.lang.Object
  extended by org.apache.cocoon.woody.formmodel.AbstractWidget
      extended by org.apache.cocoon.woody.formmodel.AbstractContainerWidget
          extended by org.apache.cocoon.woody.formmodel.Form
All Implemented Interfaces:
ContainerWidget, Widget

public class Form
extends AbstractContainerWidget

A widget that serves as a container for other widgets, the top-level widget in a form description file.

Version:
CVS $Id: Form.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Bruno Dumon, Sylvain Wallez

Field Summary
 
Fields inherited from class org.apache.cocoon.woody.formmodel.AbstractContainerWidget
widgets
 
Fields inherited from class org.apache.cocoon.woody.formmodel.AbstractWidget
definition
 
Constructor Summary
Form(FormDefinition definition)
           
 
Method Summary
 void addProcessingPhaseListener(ProcessingPhaseListener listener)
           
 void addWidgetEvent(WidgetEvent event)
          Events produced by child widgets should not be fired immediately, but queued in order to ensure an overall consistency of the widget tree before being handled.
 boolean doValidate(FormContext formContext)
           
 void endProcessing(boolean redisplayForm)
          End the current form processing after the current phase.
 void generateLabel(ContentHandler contentHandler)
          Generates SAX events for the label of this widget.
 void generateSaxFragment(ContentHandler contentHandler, Locale locale)
          Generates an XML representation of this widget.
 Object getAttribute(String name)
           
 Locale getLocale()
          Get the locale to be used to process this form.
 Widget getSubmitWidget()
          Get the widget that triggered the current processing.
 boolean isValid()
          Was form validation successful ?
 boolean process(FormContext formContext)
          Processes a form submit.
 void readFromRequest(FormContext formContext)
          Lets this widget read its data from a request.
 void removeAttribute(String name)
           
 void removeProcessingPhaseListener(ProcessingPhaseListener listener)
           
 void setAttribute(String name, Object value)
           
 void setFormHandler(FormHandler formHandler)
           
 void setSubmitWidget(Widget widget)
          Set the widget that triggered the current form processing.
 boolean validate(FormContext formContext)
          Validates this widget and returns the outcome.
 
Methods inherited from class org.apache.cocoon.woody.formmodel.AbstractContainerWidget
addWidget, generateSaxFragment, getChildren, getWidget, hasWidget
 
Methods inherited from class org.apache.cocoon.woody.formmodel.AbstractWidget
addValidator, broadcastEvent, generateItemSaxFragment, generateSaxFragment, getForm, getFullyQualifiedId, getId, getLocation, getNamespace, getParent, getValue, isRequired, removeValidator, setDefinition, setLocation, setParent, setValue
 
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
broadcastEvent, getForm, getFullyQualifiedId, getId, getLocation, getNamespace, getParent, getValue, isRequired, setParent, setValue
 

Constructor Detail

Form

public Form(FormDefinition definition)
Method Detail

addWidgetEvent

public void addWidgetEvent(WidgetEvent event)
Events produced by child widgets should not be fired immediately, but queued in order to ensure an overall consistency of the widget tree before being handled.

Parameters:
event - the event to queue

getLocale

public Locale getLocale()
Get the locale to be used to process this form.

Returns:
the form's locale.

getSubmitWidget

public Widget getSubmitWidget()
Get the widget that triggered the current processing. Note that it can be any widget, and not necessarily an action or a submit.

Returns:
the widget that submitted this form.

setSubmitWidget

public void setSubmitWidget(Widget widget)
Set the widget that triggered the current form processing.

Parameters:
widget - the widget

setFormHandler

public void setFormHandler(FormHandler formHandler)

addProcessingPhaseListener

public void addProcessingPhaseListener(ProcessingPhaseListener listener)

removeProcessingPhaseListener

public void removeProcessingPhaseListener(ProcessingPhaseListener listener)

process

public boolean process(FormContext formContext)
Processes a form submit. If the form is finished, i.e. the form should not be redisplayed to the user, then this method returns true, otherwise it returns false. To know if the form was sucessfully validated, use the isValid() method.

Form processing consists in multiple steps:

This processing can be interrupted by the widgets (or their event listeners) by calling endProcessing(boolean).


endProcessing

public void endProcessing(boolean redisplayForm)
End the current form processing after the current phase.

Parameters:
redisplayForm - indicates if the form should be redisplayed to the user.

isValid

public boolean isValid()
Was form validation successful ?

Returns:
true if the form was successfully validated.

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
Overrides:
readFromRequest in class AbstractContainerWidget

validate

public boolean validate(FormContext formContext)
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 AbstractContainerWidget

doValidate

public boolean doValidate(FormContext formContext)

getAttribute

public Object getAttribute(String name)

setAttribute

public void setAttribute(String name,
                         Object value)

removeAttribute

public void removeAttribute(String name)

generateSaxFragment

public void generateSaxFragment(ContentHandler contentHandler,
                                Locale locale)
                         throws SAXException
Description copied from interface: Widget
Generates an XML representation of this widget. The startDocument and endDocument SAX events will not be called. It is assumed that the prefix for the Woody namespace mentioned in Constants.WI_PREFIX is already declared (by the caller or otherwise).

Throws:
SAXException

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
Overrides:
generateLabel in class AbstractWidget
Throws:
SAXException


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