|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.cocoon.forms.formmodel.AbstractWidget org.apache.cocoon.forms.formmodel.MultiValueField
public class MultiValueField
A MultiValueField is mostly the same as a normal Field
, but can
hold multiple values. A MultiValueField should have a Datatype which
has a SelectionList, because the user will always select the values
from a list. A MultiValueField has no concept of "required", you should
instead use the ValueCountValidationRule to check how many items the user
has selected.
A MultiValueField also has a Datatype
associated with it. In
case of MultiValueFields, this Datatype will always be an array
type, thus Datatype.isArrayType()
will always return true, and
this in return has an influence on the kind of validation rules that
can be used with the Datatype (see Datatype
description for more
information).
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 | |
---|---|
MultiValueField(MultiValueFieldDefinition definition)
|
Method Summary | |
---|---|
void |
addValueChangedListener(ValueChangedListener listener)
|
void |
broadcastEvent(WidgetEvent event)
Broadcast an event previously queued by this widget to its event listeners. |
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. |
ValidationError |
getValidationError()
|
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. |
void |
readFromRequest(FormContext formContext)
Lets this widget read its data from a request. |
void |
removeValueChangedListener(ValueChangedListener listener)
|
void |
setSelectionList(Object model,
String valuePath,
String labelPath)
Set this field's selection list using values from an in-memory object. |
void |
setSelectionList(SelectionList selectionList)
Set this field's selection list. |
void |
setSelectionList(String uri)
Read this field's selection list from an external source. |
void |
setValidationError(ValidationError error)
|
void |
setValue(Object value)
Sets the value of this widget. |
void |
setValues(Object[] values)
|
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, 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, generateLabel, generateSaxFragment, getAttribute, getCombinedState, getForm, getFullName, getId, getLocation, getName, getParent, getRequestParameterName, getState, getWidget, isRequired, isValid, lookupWidget, removeAttribute, removeValidator, setAttribute, setParent, setState |
Constructor Detail |
---|
public MultiValueField(MultiValueFieldDefinition definition)
Method Detail |
---|
public void initialize()
AbstractWidget
initialize
in interface Widget
initialize
in class AbstractWidget
public WidgetDefinition getDefinition()
AbstractWidget
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.
getDefinition
in interface Widget
getDefinition
in class AbstractWidget
WidgetDefinition.createInstance()
)public void readFromRequest(FormContext formContext)
Widget
readFromRequest
in interface Widget
public boolean validate()
Widget
Widget.generateSaxFragment(ContentHandler, Locale)
method.
validate
in interface Widget
validate
in class AbstractWidget
true
to indicate all validations were ok,
false
otherwiseWidget.validate()
public String getXMLElementName()
AbstractWidget
AbstractWidget.generateSaxFragment(ContentHandler, Locale)
to produce the wrapping element for all the XML-instance-content of this Widget.
getXMLElementName
in class AbstractWidget
public void generateItemSaxFragment(ContentHandler contentHandler, Locale locale) throws SAXException
AbstractWidget
AbstractWidget.generateSaxFragment(ContentHandler, Locale)
The implementation on the AbstractWidget level inserts no additional XML.
Subclasses need to override to insert widget specific content.
generateItemSaxFragment
in class AbstractWidget
contentHandler
- to send the SAX events tolocale
- in which context potential content needs to be put.
SAXException
public Object getValue()
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.
getValue
in interface Widget
getValue
in class AbstractWidget
public void setValue(Object value)
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.
setValue
in interface Widget
setValue
in class AbstractWidget
value
- the new widget's value.public void setValues(Object[] values)
public void setSelectionList(SelectionList selectionList)
setSelectionList
in interface SelectableWidget
selectionList
- The new selection list.public void setSelectionList(String uri)
fd:selection-list
element.
setSelectionList
in interface SelectableWidget
uri
- The URI of the source.public void setSelectionList(Object model, String valuePath, String labelPath)
object
parameter should point to a collection
(Java collection or array, or Javascript array) of objects. Each object
belonging to the collection should have a value property and a
label property, whose values are used to specify the value
attribute and the contents of the fd:label
child element
of every fd:item
in the list.
Access to the values of the above mentioned properties is done via XPath expressions.
setSelectionList
in interface SelectableWidget
model
- The collection used as a model for the selection list.valuePath
- An XPath expression referring to the attribute used
to populate the values of the list's items.labelPath
- An XPath expression referring to the attribute used
to populate the labels of the list's items.public void broadcastEvent(WidgetEvent event)
AbstractWidget
UnsupportedOperationException
.
Concrete subclass widgets need to override when supporting event broadcasting.
broadcastEvent
in interface Widget
broadcastEvent
in class AbstractWidget
public ValidationError getValidationError()
getValidationError
in interface ValidationErrorAware
public void setValidationError(ValidationError error)
setValidationError
in interface ValidationErrorAware
public Datatype getDatatype()
getDatatype
in interface DataWidget
public void addValueChangedListener(ValueChangedListener listener)
addValueChangedListener
in interface ValueChangedListenerEnabled
public void removeValueChangedListener(ValueChangedListener listener)
removeValueChangedListener
in interface ValueChangedListenerEnabled
public boolean hasValueChangedListeners()
hasValueChangedListeners
in interface ValueChangedListenerEnabled
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |