com.iplanet.jato.view.html
Class SelectableGroupImpl

java.lang.Object
  |
  +--com.iplanet.jato.view.ViewBase
        |
        +--com.iplanet.jato.view.DisplayFieldImpl
              |
              +--com.iplanet.jato.view.html.HtmlDisplayFieldBase
                    |
                    +--com.iplanet.jato.view.html.SelectableGroupImpl
All Implemented Interfaces:
DisplayField, HtmlDisplayField, SelectableGroup, View
Direct Known Subclasses:
ComboBox, ListBox, RadioButtonGroup

public class SelectableGroupImpl
extends HtmlDisplayFieldBase
implements SelectableGroup

The SelectableGroup serves as an base class for several subclasses which encapsulate and implement the server-side representation of HTML tags comprised of multiple options (i.e. RadioButtonGroup, ListBox, ComboBox).

The SelectableGroupImpl uses an OptionList for the storage of the options collection. The concrete subclasses (RadioButtonGroup, ListBox, ComboBox) implement the details of leveraging the option list in order to generate their respective HTML.

The SelectableGroupImpl also supports a value added feature call "Label for None Selected". One can think of the "Label for None Selected" as a "reserved" option which is selected automatically when no other options are selected. While the label for none selected may be set programatically, the value is fixed to the empty string constant.

Not all SelectableGroups need supply an option for "None Selected".
This is a value added feature.
Note, that the None Selected option is never actually added to the OptionList. It is merely automatically, prepended as needed to the overall HTML string. If the label for none selected (see setLabelForNoneSelected is blank or null, then no extra option is added.
If the label for none selected is a greater than 0 length string, then it will be prepended to the list of options at the time the HTML is generated.

Special Note re: SelectableGroup/OptionList instance relationship. Clients of a SelectableGroup must be aware of the instance to instance relationship between a SelectableGroup and its OptionList. Specifically, in order to maximize runtime performance, clients may supply the same reference to a statically defined OptionList to many non staticly defined SelectableGroups.

By doing so, the cost of populating the OptionList can be reduced to a single static initialization.

This strategy is optimal for those situations where all run time instances of the specific SelectableGroup are intended to render the exact same list of options, for the entire life time of the SelectableGroup.

The drawback is that the since the same set of options are referrenced by all instances of SelectableGroup that have been affiliated with that single static instance of OptionList. clients must be careful not to adjust the OptionList, after its initial population.

If one wishes to have the Options vary from instance to instance of a given SelectableGroup then one should affiliate a non-static instance of OptionList with each instance of SelectableGroup. If that is done, when the content of a given OptionList instance is modified, only one SelectableGroup instance is affected.

Version:
JATO/1.2.2 $Id: SelectableGroupImpl.java,v 1.9 2002/03/16 03:26:45 todd Exp $
See Also:
Option, OptionList, RadioButtonGroup, ListBox, ComboBox

Fields inherited from interface com.iplanet.jato.view.html.SelectableGroup
VALUE_FOR_NONE_SELECTED
 
Fields inherited from interface com.iplanet.jato.view.html.HtmlDisplayField
QBE_CONTROL_NAME_SUFFIX
 
Fields inherited from interface com.iplanet.jato.view.View
QUALIFIED_VIEW_NAME_SEPARATOR
 
Constructor Summary
SelectableGroupImpl(ContainerView parent, java.lang.String name, java.lang.Object value)
          Construct a display field with the specified properties.
SelectableGroupImpl(ContainerView parent, java.lang.String name, java.lang.Object value, OptionList options)
          Construct a display field with the specified properties.
SelectableGroupImpl(ContainerView parent, java.lang.String name, java.lang.String boundName, java.lang.Object value)
          Construct a display field with the specified properties.
SelectableGroupImpl(ContainerView parent, java.lang.String name, java.lang.String boundName, java.lang.Object value, OptionList options)
          Construct a display field with the specified properties.
SelectableGroupImpl(View parent, Model model, java.lang.String name, java.lang.Object value)
          Construct a display field with the specified properties
SelectableGroupImpl(View parent, Model model, java.lang.String name, java.lang.Object value, OptionList options)
          Construct a display field with the specified properties
SelectableGroupImpl(View parent, Model model, java.lang.String name, java.lang.String boundName, java.lang.Object value)
          Construct a display field with the specified properties
SelectableGroupImpl(View parent, Model model, java.lang.String name, java.lang.String boundName, java.lang.Object value, DisplayFieldDescriptor descriptor)
          Construct a display field with the specified properties
SelectableGroupImpl(View parent, Model model, java.lang.String name, java.lang.String boundName, java.lang.Object value, OptionList options, DisplayFieldDescriptor descriptor)
          Construct a display field with the specified properties
 
Method Summary
 java.lang.String getLabelForNoneSelected()
          Returns the raw "Label for None Selected" string.
 java.lang.String getNoneSelectedHtmlString(boolean noneSelected)
          Returns the HTML string defining an Option consisting of the "Label for None Selected" label, and the predefined VALUE_FOR_NONE_SELECTED
 int getNumOptions()
          Returns the number of Option objects currently in the option list
 OptionList getOptions()
          Returns the OptionsList object
 boolean isMultiSelect()
          Returns true if the SelectableGroup supports selection of more than one option
 boolean isSelected(Option option)
          Returns true if the supplied Option is amongst the currently selected Options.
 boolean isSelected(java.lang.String value)
          Returns true if the supplied value is amongst the currently selected option values
 void setLabelForNoneSelected(java.lang.String labelForNoneSelected)
          Sets the raw "Label for None Selected" string.
 void setMultiSelect(boolean isMultiSelect)
          Sets the multiple selection capability for the SelectableGroup
 void setOptions(OptionList value)
          Sets the OptionsList object
 
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, getValue, getValues, setBoundName, setDescriptor, setModel, setValue, setValue, 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.html.HtmlDisplayField
getExtraHtml
 
Methods inherited from interface com.iplanet.jato.view.DisplayField
getDescriptor, getValue, getValues, setValue, setValues, stringValue
 
Methods inherited from interface com.iplanet.jato.view.View
getName, getParent, getQualifiedName, setParent
 

Constructor Detail

SelectableGroupImpl

public SelectableGroupImpl(ContainerView parent,
                           java.lang.String name,
                           java.lang.Object value)
Construct a display field with the specified properties. The field will be bound to the parent's default model.
Parameters:
parent - The parent view of this object
name - This view's name and model field bound name
value - This DiplayField's initial value.

SelectableGroupImpl

public SelectableGroupImpl(ContainerView parent,
                           java.lang.String name,
                           java.lang.Object value,
                           OptionList options)
Construct a display field with the specified properties. The field will be bound to the parent's default model.
Parameters:
parent - The parent view of this object
name - This view's name and model field bound name
value - This DiplayField's initial value.

SelectableGroupImpl

public SelectableGroupImpl(ContainerView parent,
                           java.lang.String name,
                           java.lang.String boundName,
                           java.lang.Object value)
Construct a display field with the specified properties. The field will be bound to the parent's default model.
Parameters:
parent - The parent view of this object
name - This view's name
boundName - The name of the model field to which this DisplayField is bound
value - This DiplayField's initial value.

SelectableGroupImpl

public SelectableGroupImpl(ContainerView parent,
                           java.lang.String name,
                           java.lang.String boundName,
                           java.lang.Object value,
                           OptionList options)
Construct a display field with the specified properties. The field will be bound to the parent's default model.
Parameters:
parent - The parent view of this object
name - This view's name
boundName - The name of the model field to which this DisplayField is bound
value - This DiplayField's initial value.

SelectableGroupImpl

public SelectableGroupImpl(View parent,
                           Model model,
                           java.lang.String name,
                           java.lang.Object value)
Construct a display field with the specified properties
Parameters:
parent - The parent view of this object
model - The model to which this DisplayField is bound
name - This view's name and model field bound name
value - This DiplayField's initial value.

SelectableGroupImpl

public SelectableGroupImpl(View parent,
                           Model model,
                           java.lang.String name,
                           java.lang.Object value,
                           OptionList options)
Construct a display field with the specified properties
Parameters:
parent - The parent view of this object
model - The model to which this DisplayField is bound
name - This view's name and model field bound name
value - This DiplayField's initial value.

SelectableGroupImpl

public SelectableGroupImpl(View parent,
                           Model model,
                           java.lang.String name,
                           java.lang.String boundName,
                           java.lang.Object value)
Construct a display field with the specified properties
Parameters:
parent - The parent view of this object
model - The model to which this DisplayField is bound
name - This view's name.
boundName - The name of the model field to which this DisplayField is bound
value - This DiplayField's initial value.

SelectableGroupImpl

public SelectableGroupImpl(View parent,
                           Model model,
                           java.lang.String name,
                           java.lang.String boundName,
                           java.lang.Object value,
                           DisplayFieldDescriptor descriptor)
Construct a display field with the specified properties
Parameters:
parent - The parent view of this object
model - The model to which this DisplayField is bound
name - This view's name.
boundName - The name of the model field to which this DisplayField is bound
value - This DiplayField's initial value.
descriptor - This DisplayField's DisplayFieldDescriptor. May be null.

SelectableGroupImpl

public SelectableGroupImpl(View parent,
                           Model model,
                           java.lang.String name,
                           java.lang.String boundName,
                           java.lang.Object value,
                           OptionList options,
                           DisplayFieldDescriptor descriptor)
Construct a display field with the specified properties
Parameters:
parent - The parent view of this object
model - The model to which this DisplayField is bound
name - This view's name.
boundName - The name of the model field to which this DisplayField is bound
value - This DiplayField's initial value.
descriptor - This DisplayField's DisplayFieldDescriptor. May be null.
Method Detail

isMultiSelect

public boolean isMultiSelect()
Returns true if the SelectableGroup supports selection of more than one option
Specified by:
isMultiSelect in interface SelectableGroup
Returns:
true if the SelectableGroup supports selection of more than one option

setMultiSelect

public void setMultiSelect(boolean isMultiSelect)
Sets the multiple selection capability for the SelectableGroup
Specified by:
setMultiSelect in interface SelectableGroup
Parameters:
isMultiSelect - Determines whether this selectable group supports selection of more than one option at a time

getNumOptions

public int getNumOptions()
Returns the number of Option objects currently in the option list
Specified by:
getNumOptions in interface SelectableGroup
Returns:
the number of Option objects currently in the option list

getOptions

public OptionList getOptions()
Returns the OptionsList object
Specified by:
getOptions in interface SelectableGroup
Returns:
the OptionsList object

setOptions

public void setOptions(OptionList value)
Sets the OptionsList object
Specified by:
setOptions in interface SelectableGroup
Parameters:
options - the OptionsList object

getNoneSelectedHtmlString

public java.lang.String getNoneSelectedHtmlString(boolean noneSelected)
Returns the HTML string defining an Option consisting of the "Label for None Selected" label, and the predefined VALUE_FOR_NONE_SELECTED
Specified by:
getNoneSelectedHtmlString in interface SelectableGroup
Parameters:
noneSelected - if true, the "None Selected" option is selected
Returns:
the HTML string for a NoneSelected option

getLabelForNoneSelected

public java.lang.String getLabelForNoneSelected()
Returns the raw "Label for None Selected" string. As opposed to getNoneSelectedHtmlString() which returns a full- blown Option string.
Specified by:
getLabelForNoneSelected in interface SelectableGroup
Returns:
The raw "Label for None Selected" string

setLabelForNoneSelected

public void setLabelForNoneSelected(java.lang.String labelForNoneSelected)
Sets the raw "Label for None Selected" string.
Specified by:
setLabelForNoneSelected in interface SelectableGroup
Parameters:
labelForNoneSelected - the raw "Label for None Selected" string

isSelected

public boolean isSelected(java.lang.String value)
Returns true if the supplied value is amongst the currently selected option values
Specified by:
isSelected in interface SelectableGroup
Parameters:
value - The value to be compared with any currently selected option values
Returns:
True if the supplied value corresponds to a selected option

isSelected

public boolean isSelected(Option option)
Returns true if the supplied Option is amongst the currently selected Options.

Note - this does not perform an equivalency between the Option instance passed in as an argument and the currently selected options(s).
Rather, it compares the value component of the Option parameter with the value component of the currently selected options(s).

Specified by:
isSelected in interface SelectableGroup
Parameters:
option - The Option to be compared with any currently selected option Options
Returns:
true if the supplied Options' value corresponds to a selected option