org.apache.cocoon.woody.formmodel
Class Union

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.Union
All Implemented Interfaces:
ContainerWidget, Widget

public class Union
extends AbstractContainerWidget

A discriminated union that references a discriminant value in another widget and contains one of several cases (widgets). To have a case hold more than one widget or to use a different id for the case than for the widget id, just wrap the widget(s) in a container widget named with the desired case id.

Version:
$Id: Union.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Timothy Larson

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
Union(UnionDefinition definition)
           
 
Method Summary
 void generateItemsSaxFragment(ContentHandler contentHandler, Locale locale)
           
 void generateSaxFragment(ContentHandler contentHandler, Locale locale)
          Generates an XML representation of this widget.
 String getElementName()
           
 Object getValue()
          Returns the value of the widget.
 Widget getWidget(String id)
          Gets the child widget of this widget with the given id, or null if there isn't such a child.
 void readFromRequest(FormContext formContext)
          Lets this widget read its data from a request.
 void resolve()
           
 void setParent(Widget widget)
          This method is called on a widget when it is added to a container.
 boolean validate(FormContext formContext)
          Validates this widget and returns the outcome.
 
Methods inherited from class org.apache.cocoon.woody.formmodel.AbstractContainerWidget
addWidget, generateSaxFragment, getChildren, hasWidget
 
Methods inherited from class org.apache.cocoon.woody.formmodel.AbstractWidget
addValidator, broadcastEvent, generateItemSaxFragment, generateLabel, generateSaxFragment, getForm, getFullyQualifiedId, getId, getLocation, getNamespace, getParent, isRequired, removeValidator, setDefinition, setLocation, 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, generateLabel, getForm, getFullyQualifiedId, getId, getLocation, getNamespace, getParent, isRequired, setValue
 

Constructor Detail

Union

public Union(UnionDefinition definition)
Method Detail

setParent

public void setParent(Widget widget)
Description copied from interface: Widget
This method is called on a widget when it is added to a container. You shouldn't call this method unless youre implementing a widget yourself (in which case it should be called when a widget is added as child of your widget).

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

resolve

public void resolve()

getElementName

public String getElementName()

getValue

public Object getValue()
Description copied from interface: Widget
Returns the value of the widget. For some widgets (notably ContainerWidgets) this may not make sense, those should then simply return null here.

Specified by:
getValue in interface Widget
Overrides:
getValue 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
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

getWidget

public Widget getWidget(String id)
Description copied from interface: Widget
Gets the child widget of this widget with the given id, or null if there isn't such a child.

Specified by:
getWidget in interface ContainerWidget
Specified by:
getWidget in interface Widget
Overrides:
getWidget in class AbstractContainerWidget

generateItemsSaxFragment

public void generateItemsSaxFragment(ContentHandler contentHandler,
                                     Locale locale)
                              throws SAXException
Throws:
SAXException

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


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