|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.taursys.xml.Component com.taursys.xml.Parameter com.taursys.xml.AbstractField com.taursys.xml.CheckboxField
This component is used to display and change a "selected indicator".
This component uses a DefaultCheckboxModel
to manage the
state. There are only two states for this component: selected or
not-selected.
To use this component you must first set the the following properties as indicated:
selectedValue
- the text value which indicates a
"selected" state. The default value is "true".unselectedValue
- the text value which indicates an
"un-selected" state. The default value is "" (blank) which will result
in a null
value being stored in the valueHolder
This component can function in three different ways, depending on the properties you set:
parameter
property.id
property.parameter
and
id
properties.When used for output, the value is rendered in the XML document as a
text node by default. If you want the value to be rendered to
an attribute of the node instead, you must change the renderer
to an AttributeTextFieldRenderer
and the the attribute
property to the name of the attribute. For rendering with an
HTML input type checkbox, use the HTMLCheckBox
component.
When used for input, this component receives its value from the
InputDispatcher
AFTER the openForm
method of the
ServletForm
by default. If you want this component to receive
its input earlier (at the same time as Parameters
), set the
earlyInputNotify
property to true
.
By default, this component uses a DefaultCheckboxModel
.
You can change this by overriding the createDefaultModel
method
or explicitly setting the model
property.
This component can be used in a variety of ways. It can be used in an un-bound mode, where the current selected state is maintained internally. It can also be used in a bound mode where the current selected state is propagated to a value holder. When used in the bound mode a single property can be set in the value holder. The following sections describe the required settings to make for each of the modes.
Un-bound ModeTo use this component in the un-bound mode, you can set the following properties:
selectedValue
- the text value which indicates a
"selected" state. The default value is "true".unselectedValue
- the text value which indicates an
"un-selected" state. The default value is "" (blank) which will result
in a null
value being stored in the valueHolder
To use this component in the bound mode, use the same properties as described in the Un-bound Mode, plus the following additional properties:
valueHolder
- should be bound to the
ValueHolder
which contains the current selected state and is to
be updated if the state is changed.propertyName
- set this to the property
name (belonging to the object in the ValueHolder
) which will
be bound to the selected state. Example: given a ValueHolder
with an "Address" object which has a "active" property, use
setPropertyName("active")
to store the current selected state in
the "Address.active" property.
Constructor Summary | |
CheckboxField()
Constructs a new CheckboxField with a default model and renderer. |
|
CheckboxField(int javaDataType)
Constructs a new CheckboxField for the given datatype with a default model and renderer. |
Method Summary | |
protected TextModel |
createDefaultModel()
Creates the default TextModel used by this component By default, this method returns a new DefaultCheckboxModel. |
protected TextModel |
createDefaultModel(int javaDataType)
Creates the default model of given data type used by this component |
protected CheckboxFieldRenderer |
createDefaultRenderer()
Creates the default CheckboxFieldRenderer for this component. |
protected CheckboxModel |
getCheckboxModel()
Returns the current model cast as a SelectModel |
CheckboxFieldRenderer |
getRenderer()
Returns the renderer subcomponent used to render the value to the Document. |
java.lang.String |
getSelectedValue()
Get the value used to indicate a selected state. |
java.lang.String |
getText()
Returns the model value as a String (using Format if defined). |
java.lang.String |
getUnselectedValue()
Get the value used to indicate an unselected state. |
boolean |
isSelected()
Gets the current selected state from the Model. |
void |
processRenderEvent(RenderEvent e)
Responds to a render event for this component. |
void |
setModel(TextModel newModel)
Sets the Model for this component to the given CheckboxModel. |
void |
setRenderer(CheckboxFieldRenderer newRenderer)
Sets the renderer subcomponent used to render the value to the Document. |
void |
setSelected(boolean newSelected)
Sets the current state as selected(true) or unselected(false) for the model. |
void |
setSelectedValue(java.lang.String newSelectedValue)
Set the value used to indicate a selected state. |
void |
setText(java.lang.String text)
Sets the model value from the given String (using Format if defined). |
void |
setUnselectedValue(java.lang.String newUnselectedValue)
Set the value used to indicate an unselected state. |
Methods inherited from class com.taursys.xml.Parameter |
getDefaultValue, getFormat, getFormatPattern, getModel, getParameter, getPropertyName, getValue, getValueHolder, processParameterEvent, setDefaultValue, setFormat, setFormatPattern, setParameter, setPropertyName, setValue |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public CheckboxField()
public CheckboxField(int javaDataType)
javaDataType
- data type for new modelfor defined data type constants TYPE_XXX.
Method Detail |
protected TextModel createDefaultModel()
createDefaultModel
in class Parameter
protected TextModel createDefaultModel(int javaDataType)
createDefaultModel
in class Parameter
javaDataType
- data type for new modelfor defined data type constants TYPE_XXX.
public void setModel(TextModel newModel) throws java.lang.IllegalArgumentException
setModel
in class Parameter
newModel
- to be used by this component.
java.lang.IllegalArgumentException
- if newModel is not instance of CheckboxModelprotected CheckboxModel getCheckboxModel()
protected CheckboxFieldRenderer createDefaultRenderer()
public void setRenderer(CheckboxFieldRenderer newRenderer)
public CheckboxFieldRenderer getRenderer()
public java.lang.String getText() throws ModelException
getText
in class Parameter
ModelException
public void setText(java.lang.String text) throws ModelException
setText
in class Parameter
ModelException
public boolean isSelected() throws ModelException
UnknownStateValueException
- if the internal value does not match a
known state text value.
ModelException
- if problem while setting properties of object in
valueHolder.public void setSelected(boolean newSelected) throws ModelException
ModelException
- if problem while setting properties of object in
valueHolder.public void processRenderEvent(RenderEvent e) throws RenderException
processRenderEvent
in class AbstractField
e
- the current render event message
RenderException
- if problem rendering value to documentpublic void setSelectedValue(java.lang.String newSelectedValue)
newSelectedValue
- the value used to indicate a selected state.public java.lang.String getSelectedValue()
public void setUnselectedValue(java.lang.String newUnselectedValue)
newUnselectedValue
- the value used to indicate a unselected state.public java.lang.String getUnselectedValue()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |