|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.iplanet.jato.view.ViewBase | +--com.iplanet.jato.view.DisplayFieldImpl | +--com.iplanet.jato.view.html.HtmlDisplayFieldBase | +--com.iplanet.jato.view.html.CheckBox
The CheckBox class encapsulates and implements the server-side representation of an HTML check box statement.
The API has been designed to favor the boolean nature of a check box. It is generally recommended that clients use the boolean accessor/mutator (isChecked() and setChecked(boolean)) whenever possible as opposed to the object based accessor/mutators ( getValue(), setValue(Object) ).
Notes on the distinction between value, checked value and unchecked value
Each checkbox may define a checked value and an unchecked value. For example, assume that the checkbox creator has designated that the checked value be "T" and the unchecked value be "F". These assignments are made via the setCheckedValue(Object) and setUncheckedValue(Object) methods. The actual values are arbitrary.
The checked value is the value that is encoded into the checkbox's HTML string. This is the value that is returned as a request parameter when an HTML form is submitted with a checked checkbox.
e.g. for a sample checkbox html The checked value in this example is "T"
The unchecked value in this example not evident in the HTML. There is no HTML provision for embedding an unchecked value in the HTML. In fact, unchecked checkboxes are not returned as request parameters at all. The server has to infer the unchecked value based on the absence of a given checkbox from the request parameter list.
The display field "value", distinct from the checked value and unchecked value, is the value that is stored in this display field's bound model. This is behavior consistent with all display fields.
This checkbox implementation has been careful to ensure that the field "value" is set to either the checked value or unchecked value. The only exception is for a Boolean object which might be mapped into the model directly via a data retrieval. In that case this implementation, will evaluate the Boolean.booleanValue() and map it to the corresponding checked state or unchecked state.
Fields inherited from interface com.iplanet.jato.view.View |
QUALIFIED_VIEW_NAME_SEPARATOR |
Fields inherited from interface com.iplanet.jato.view.html.HtmlDisplayField |
QBE_CONTROL_NAME_SUFFIX |
Constructor Summary | |
CheckBox(ContainerView parent,
java.lang.String name,
java.lang.Object checkedValue,
java.lang.Object uncheckedValue,
boolean checked)
Construct a minimal instance using the parent's default model and the field's name as its bound name |
|
CheckBox(View parent,
Model model,
java.lang.String name,
java.lang.Object checkedValue,
java.lang.Object uncheckedValue,
boolean checked)
Construct a minimal instance using the parent's default model and the field's name as its bound name |
|
CheckBox(View parent,
Model model,
java.lang.String name,
java.lang.String boundName,
java.lang.Object checkedValue,
java.lang.Object uncheckedValue,
boolean checked,
DisplayFieldDescriptor descriptor)
This constructor can be used when creating a CheckBox directly |
Method Summary | |
boolean |
booleanValue()
Returns the boolean state of the field derived from the current value. |
java.lang.Object |
getCheckedValue()
Returns the value that has been designated as the "checked value" This is the value that is encoded into the checkbox's HTML string. |
java.lang.Object |
getFalseValue()
Same as getUncheckedValue() |
java.lang.Object |
getTrueValue()
Same as getCheckedValue() |
java.lang.Object |
getUncheckedValue()
Returns the value that has been designated as the "unchecked value" Contrary to the checked value, the unchecked value is NOT encoded in the checkbox's HTML string, since there is no HTML attribute. |
java.lang.Object |
getValue()
This version will defensively check to see if the model value is a Boolean object. |
boolean |
isChecked()
Returns true if the current display field value is equal to the the checked value. |
void |
setChecked(boolean value)
Checks or unchecks the check box |
void |
setCheckedValue(java.lang.Object value)
Sets the value to be associated with the checked state. |
void |
setUncheckedValue(java.lang.Object value)
Sets the value to be associated with the unchecked state. |
void |
setValue(java.lang.Object value)
Sets the check box value. |
void |
setValue(java.lang.Object value,
boolean overwrite)
Sets the check box value |
Methods inherited from class com.iplanet.jato.view.html.HtmlDisplayFieldBase |
getExtraHtml, getQBEControlQualifiedName, setExtraHtml, urlEncodedValue |
Methods inherited from class com.iplanet.jato.view.DisplayFieldImpl |
getBoundName, getDescriptor, getModel, getValues, setBoundName, setDescriptor, setModel, setValues, setValues, stringValue |
Methods inherited from class com.iplanet.jato.view.ViewBase |
getName, getParent, getParentViewBean, getQualifiedName, getRootView, getRootView, setName, setParent |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.iplanet.jato.view.DisplayField |
getDescriptor, getValues, setValues, stringValue |
Methods inherited from interface com.iplanet.jato.view.View |
getName, getParent, getQualifiedName, setParent |
Constructor Detail |
public CheckBox(ContainerView parent, java.lang.String name, java.lang.Object checkedValue, java.lang.Object uncheckedValue, boolean checked)
parent
- The parent view of this objectname
- This view's name and model bound namecheckedValue
- The value that will be associated with a selected check boxuncheckedValue
- The value that will be associated with an unselected check boxchecked
- if true, this field's value is set to its true value
if false, this field's value is set to its false valuepublic CheckBox(View parent, Model model, java.lang.String name, java.lang.Object checkedValue, java.lang.Object uncheckedValue, boolean checked)
parent
- The parent view of this objectmodel
- The model to which this DisplayField is boundname
- This view's name and model bound namecheckedValue
- The value that will be associated with a selected check boxuncheckedValue
- The value that will be associated with an unselected check boxchecked
- if true, this field's value is set to its true value
if false, this field's value is set to its false valuepublic CheckBox(View parent, Model model, java.lang.String name, java.lang.String boundName, java.lang.Object checkedValue, java.lang.Object uncheckedValue, boolean checked, DisplayFieldDescriptor descriptor)
parent
- The parent view of this objectmodel
- The model to which this DisplayField is boundname
- This view's name.boundName
- The name of the model field to which this DisplayField is boundcheckedValue
- The value that will be associated with a selected check boxuncheckedValue
- The value that will be associated with an unselected check boxchecked
- if true, this field's value is set to its true value
if false, this field's value is set to its false valuedescriptor
- This DisplayField's DisplayFieldDescriptor. May be null.Method Detail |
public boolean isChecked()
booleanValue()
public void setChecked(boolean value)
value
- if true then field is checked, otherwise field is uncheckedpublic void setValue(java.lang.Object value)
setValue
in interface DisplayField
setValue
in class DisplayFieldImpl
value
- The value is compared to this fields "checked value" and
"unchecked value". If the value matches either of these
legal values, then the field value is adjusted. Otherwise
an IllegalArgumentException will be thrownjava.lang.IllegalArgumentException
- Thrown if the incoming value does not match either the checked
value or the unchecked value.public void setValue(java.lang.Object value, boolean overwrite)
setValue
in class DisplayFieldImpl
value
- The value is compared to this fields "checked value" and
"unchecked value". If the value matches either of these
legal values, then the field value is adjusted. Otherwise
an IllegalArgumentException will be thrownoverwrite
- specifies whether to overwrite an already existing valuejava.lang.IllegalArgumentException
- Thrown if the incoming value does not match either the checked
value or the unchecked value.public java.lang.Object getValue()
If the model value is a Boolean then this method will return the field's checkedValue or uncheckedValue according to the Boolean state.
If the model value is not a Boolean value then this method will simple return the raw model value.
getValue
in interface DisplayField
getValue
in class DisplayFieldImpl
public java.lang.Object getCheckedValue()
See class description for details on relation between value, checked value and unchecked value.
getTrueValue()
public void setCheckedValue(java.lang.Object value)
See class description for details on relation between value, checked value and unchecked value.
value
- The checked valuepublic java.lang.Object getUncheckedValue()
See class description for details on relation between value, checked value and unchecked value.
getFalseValue()
public void setUncheckedValue(java.lang.Object value)
See class description for details on relation between value, checked value and unchecked value.
value
- The unchecked valuepublic boolean booleanValue()
DisplayField.getValue()
matches the value of
getTrueValue()
, this method will return true
.booleanValue
in interface BooleanDisplayField
isChecked()
public java.lang.Object getTrueValue()
getTrueValue
in interface BooleanDisplayField
getCheckedValue()
public java.lang.Object getFalseValue()
getFalseValue
in interface BooleanDisplayField
getUncheckedValue()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |