org.apache.cocoon.woody.formmodel
Class BooleanField

java.lang.Object
  extended by org.apache.cocoon.woody.formmodel.AbstractWidget
      extended by org.apache.cocoon.woody.formmodel.BooleanField
All Implemented Interfaces:
Widget

public class BooleanField
extends AbstractWidget

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

Version:
$Id: BooleanField.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Constructor Summary
BooleanField(BooleanFieldDefinition definition)
           
 
Method Summary
 void broadcastEvent(WidgetEvent event)
          Broadcast an event previously queued by this widget to its event listeners.
 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.
 String getId()
          Gets the id of this widget.
 Object getValue()
          Returns the value of the widget.
 void readFromRequest(FormContext formContext)
          Lets this widget read its data from a request.
 void setValue(Object object)
          Sets value of the field.
 boolean validate(FormContext formContext)
          Always return true (an action has no validation)
 
Methods inherited from class org.apache.cocoon.woody.formmodel.AbstractWidget
addValidator, generateItemSaxFragment, generateSaxFragment, getForm, getFullyQualifiedId, getLocation, getNamespace, getParent, getWidget, isRequired, removeValidator, setDefinition, setLocation, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BooleanField

public BooleanField(BooleanFieldDefinition definition)
Method Detail

getId

public String getId()
Description copied from class: AbstractWidget
Gets the id of this widget.

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


validate

public boolean validate(FormContext formContext)
Always return true (an action has no validation)

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

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

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

setValue

public void setValue(Object object)
Sets value of the field. If value is null, it is considered to be false (see class comment).

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

broadcastEvent

public void broadcastEvent(WidgetEvent event)
Description copied from interface: Widget
Broadcast an event previously queued by this widget to its event listeners.

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


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