|
||||||||||
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.BooleanField
public class BooleanField
A widget to select a boolean value. Usually rendered as a checkbox.
You may wonder why we don't use a Field
widget with an associated
Boolean Datatype instead. The reason is that many of the features of the Field
widget are overkill for a Boolean: validation is unnecessary (if the field is
not true it is false), the selectionlist associated with a Datatype also
has no purpose here (there would always be only 2 choices: true or false),
and the manner in which the request parameter of this widget is interpreted
is different (missing or empty request parameter means 'false', rather than null value).
Field Summary | |
---|---|
protected ValidationError |
validationError
|
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 | |
---|---|
BooleanField(BooleanFieldDefinition definition)
|
Method Summary | |
---|---|
void |
addValueChangedListener(ValueChangedListener listener)
Adds a ValueChangedListener to this widget instance. |
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. |
WidgetDefinition |
getDefinition()
Concrete subclasses should allow access to their underlaying Definition through this method. |
ValidationError |
getValidationError()
Returns the validation error, if any. |
Object |
getValue()
Get the value of a widget. |
protected AttributesImpl |
getXMLElementAttributes()
The XML attributes used in AbstractWidget.generateSaxFragment(ContentHandler, Locale)
to be placed on the wrapping element for all the XML-instance-content of this 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 |
setValidationError(ValidationError error)
Set a validation error on this field. |
void |
setValue(Object object)
Sets value of the field. |
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, isRequired, isValid, lookupWidget, removeAttribute, removeValidator, setAttribute, setParent, setState, toString, validate, widgetNameChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected ValidationError validationError
Constructor Detail |
---|
public BooleanField(BooleanFieldDefinition definition)
Method Detail |
---|
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 initialize()
AbstractWidget
initialize
in interface Widget
initialize
in class AbstractWidget
public void readFromRequest(FormContext formContext)
Widget
readFromRequest
in interface Widget
public ValidationError getValidationError()
AbstractWidget.validate()
method returned false.
getValidationError
in interface ValidationErrorAware
public void setValidationError(ValidationError error)
setValidationError
in interface ValidationErrorAware
error
- the validation errorpublic 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
protected AttributesImpl getXMLElementAttributes()
AbstractWidget
AbstractWidget.generateSaxFragment(ContentHandler, Locale)
to be placed on the wrapping element for all the XML-instance-content of this Widget.
This automatically adds @id=AbstractWidget.getRequestParameterName()
to that element.
Concrete subclasses should call super.getXMLElementAttributes and possibly
add additional attributes.
Note: the @id is not added for those widgets who's getId() returns null
(e.g. top-level container widgets like 'form'). The contract of returning a non-null
AttributesImpl
is however maintained.
getXMLElementAttributes
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 object)
setValue
in interface Widget
setValue
in class AbstractWidget
object
- the new widget's value.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
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |