Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cocoon.forms.formmodel
Class AggregateField

    java.lang.Object
      org.apache.cocoon.forms.formmodel.AbstractWidget
          org.apache.cocoon.forms.formmodel.Field
              org.apache.cocoon.forms.formmodel.AggregateField

All Implemented Interfaces:
  ContainerWidget, DataWidget, org.apache.cocoon.util.location.Locatable, SelectableWidget, ValidationErrorAware, ValueChangedListenerEnabled, Widget

public class AggregateField
extends Field
implements ContainerWidget

An aggregated field allows to represent one value as multiple input fields, or several values as one field. Hence this widget is a field and a container widget simultaneously.

Upon submit, it first attempts to read own value from the request, and splits over nested field widgets using a regular expression. If split fails, this will simply give a validation error. If own value was not submitted, it attempts to read values for nested field widgets, and combines theirs values using combine expression.

To validate this widget, both the validation rules of the nested widgets are checked, and those of the aggregated field themselves. The validation rules of the aggregated field can perform checks on the string as entered by the user (e.g. check its total length).

This field and nested fields can be of any supported type, as long as combine expression gives result of the correct type, and split regular expression can split string representation into parts which can be converted to the values of nested fields.

Version:
  $Id: AggregateField.java 587759 2007-10-24 03:00:37Z vgritsenko $

Field Summary

Fields inherited from class org.apache.cocoon.forms.formmodel.Field
`enteredValue, required, selectionList, SUGGESTED_LABEL_ATTR, validationError, value, VALUE_DISPLAY_PARSE_ERROR, VALUE_DISPLAY_VALIDATION, VALUE_PARSE_ERROR, VALUE_PARSED, VALUE_UNPARSED, VALUE_VALIDATED, VALUE_VALIDATING, valueState`

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
`AggregateField(AggregateFieldDefinition definition)`

Method Summary
`void` | `addChild(Widget widget)` Adds a child widget.
`protected void` | `addField(Field field)`
`void` | `combineFields()`
`AggregateFieldDefinition` | `getAggregateFieldDefinition()`
`Widget` | `getChild(String id)` Gets the child widget with the given id.
`Iterator` | `getChildren()`
`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` | `hasChild(String id)` Checks if there is a child widget with the given id.
`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.
`void` | `readFromRequest(FormContext formContext)` Lets this widget read its data from a request.
`void` | `setValue(Object newValue)` Sets the value of this widget.
`boolean` | `validate()` Validates this widget and returns the outcome.

Methods inherited from class org.apache.cocoon.forms.formmodel.Field
`addValueChangedListener, applyWhitespaceTrim, broadcastEvent, generateItemSaxFragment, getDatatype, getDefinition, getFieldDefinition, getSuggestionLabel, getSuggestionList, getValidationError, getValue, getXMLElementAttributes, hasValueChangedListeners, isRequired, isSuggested, readFromRequest, removeValueChangedListener, setRequired, setSelectionList, setSelectionList, setSelectionList, setSuggestionLabel, setValidationError`

Methods inherited from class org.apache.cocoon.forms.formmodel.AbstractWidget
`addValidator, generateDisplayData, generateLabel, generateSaxFragment, getAttribute, getCombinedState, getForm, getFullName, getId, getLocation, getName, getParent, getRequestParameterName, getState, getWidget, isValid, 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, broadcastEvent, generateLabel, generateSaxFragment, getAttribute, getCombinedState, getDefinition, getForm, getFullName, getId, getLocation, getName, getParent, getRequestParameterName, getState, getValue, getWidget, isRequired, isValid, lookupWidget, removeAttribute, removeValidator, setAttribute, setParent, setState`

Constructor Detail

### AggregateField

    public AggregateField(AggregateFieldDefinition definition)

Method Detail

### getAggregateFieldDefinition

    public final AggregateFieldDefinition getAggregateFieldDefinition()

### initialize

    public void initialize()

  Description copied from interface: `Widget`
  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 `Field`

### addChild

    public void addChild(Widget widget)

  Description copied from interface: `ContainerWidget`
  Adds a child widget.

  Specified by:
    `addChild` in interface `ContainerWidget`

### addField

    protected void addField(Field field)

### hasChild

    public boolean hasChild(String id)

  Description copied from interface: `ContainerWidget`
  Checks if there is a child widget with the given id.

  Specified by:
    `hasChild` in interface `ContainerWidget`

### getChildren

    public Iterator getChildren()

  Specified by:
    `getChildren` in interface `ContainerWidget`
  Returns:
    an iterator over the widgets this object contains

### 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 `Field`

### setValue

    public void setValue(Object newValue)

  Description copied from interface: `Widget`
  Sets the value of this widget.

  Not all widgets do have a value (notably `ContainerWidget`s, 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 `Field`

### combineFields

    public void combineFields()

### 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 `Field`
  See Also:
    `Widget.validate()`

### 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.

  Overrides:
    `getXMLElementName` in class `Field`
  Returns:
    "aggregatefield"

### getChild

    public Widget getChild(String id)

  Description copied from interface: `ContainerWidget`
  Gets the child widget with the given id.

  Specified by:
    `getChild` in interface `ContainerWidget`
  Overrides:
    `getChild` in class `AbstractWidget`
  Parameters:
    `id` - of the child-widget
  Returns:
    `null` if not overriden.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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