com.sas.servlet.tbeans.form
Class BaseChoiceBox

com.sas.servlet.tbeans.form.BaseChoiceBox
All Implemented Interfaces:
com.sas.beans.PropertyChangeSource, com.sas.lang.ObjectDataInterface, FormElementModificationEventInterface, com.sas.servlet.tbeans.form.JavaScriptObjectCreationInterface, com.sas.servlet.tbeans.JavaScriptEventHandlerInterface, RenderableInterface, TransformationInterface, GenericValidatorInterface, com.sas.util.WriteToPrintWriterInterface, java.io.Serializable
Direct Known Subclasses:
BaseComboBoxView, ChoiceBox

public abstract class BaseChoiceBox

The BaseChoiceBox is an abstract TransformationBean™ for creating a ChoiceBox. A ChoiceBox is a drop-down combo that allows a single selection.

The ChoiceBox TransformationBean™ gathers the selections from a model via the setModel method. A model must implement the javax.swing.ComboBoxModel interface in order to be used.

Note that subclasses of this bean actually provide the markup rendering used in/with Servlet and JavaServer Pages technologies. If you need to add support for a markup language that is not explicitly provided with AppDev Studio, then you must extend this class.

For More Information:

JSP custom tags provide an alternative to using the TransformationBeans™. Visit the Custom Tag Library Reference for additional information on the sas:ChoiceBox custom tag.

Note: A snapshot of the AppDev Studio Developers Site is installed on your local Web server when you install AppDev Studio. To access the site from webAF, select Help -> Developer Site .

See Also:
Serialized Form

Field Summary
protected  com.sas.util.transforms.TransformInterface labelTransform
           
protected  javax.swing.ComboBoxModel model
          The model for the ChoiceBox.
static java.lang.String RB_KEY
          Key used to lookup resources in the resource bundle.
 
Constructor Summary
BaseChoiceBox()
          Construct a new ChoiceBox object.
 
Method Summary
 javax.swing.ComboBoxModel getModel()
          Return the model for the ChoiceBox.
 int getSelectedIndex()
          Gets the index of single item to be marked as selected.
 java.lang.String getSelectedItem()
          Gets the value of a single item to be marked as selected.
protected  java.lang.String getValueItemLabel(com.sas.util.ValueItem item)
           
protected  boolean isSelected(int index)
          Determines if the given index should be marked as selected
protected  boolean isSelected(java.lang.String value)
          Determines if the given value should be marked as selected
 boolean isValidateSelection()
          Returns whether or not exceptions are thrown for setSelectedIndex() and setSelectedItem().
 void setModel(javax.swing.ComboBoxModel comboBoxModel)
          Sets the model for the ChoiceBox.
 void setSelectedIndex(int value)
          Sets the index of single item to be marked as selected.
 void setSelectedItem(java.lang.String value)
          Sets the value of a single item to be marked as selected.
 void setSelectedItem(java.lang.String value, int defaultIndex)
          Sets the value of a single item to be marked as selected.
 void setValidateSelection(boolean value)
          Determines whether or not exceptions are thrown for setSelectedIndex() and setSelectedItem().
 
Methods inherited from class com.sas.servlet.tbeans.form.BaseFormElement
getAccessKey, getErrorHandler, getModificationEventName, getName, getOnBlur, getOnChange, getOnClick, getOnDblClick, getOnFocus, getOnKeyDown, getOnKeyPress, getOnKeyUp, getOnMouseDown, getOnMouseMove, getOnMouseOut, getOnMouseOver, getOnMouseUp, getOnSelect, getStyleInfo, getTabIndex, getTitle, getValidationFunctions, getValidator, isEnabled, isValid, isValidationEnabled, setAccessKey, setEnabled, setErrorHandler, setId, setModificationEventName, setName, setOnBlur, setOnChange, setOnClick, setOnDblClick, setOnFocus, setOnKeyDown, setOnKeyPress, setOnKeyUp, setOnMouseDown, setOnMouseMove, setOnMouseOut, setOnMouseOver, setOnMouseUp, setOnSelect, setStyleInfo, setTabIndex, setTitle, setValidator, write, writeJavaScriptObject, writeJavaScriptObjectValidate, writeJavaScriptValidatorObject, writeValidationScript
 
Methods inherited from class com.sas.servlet.tbeans.BaseTransformation
addPropertyChangeListener, addPropertyChangeListener, cleanUpResources, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getCustomAttributes, getDescription, getId, getInputTransform, getLocale, getObjectData, getObjectDataProperty, getOutputTransform, getRequest, getResponse, getTagEpilog, getTagProlog, hasListeners, isCleanUpResourcesOn, isVisible, removePropertyChangeListener, removePropertyChangeListener, setCleanUpResourcesOn, setCustomAttributes, setDescription, setInputTransform, setLocale, setLocaleDependentProperties, setObjectData, setObjectDataProperty, setOutputTransform, setRequest, setResponse, setTagEpilog, setTagProlog, setVisible, toString, write, write, write
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
Key used to lookup resources in the resource bundle.

See Also:
Constant Field Values

labelTransform

protected com.sas.util.transforms.TransformInterface labelTransform

model

protected javax.swing.ComboBoxModel model
The model for the ChoiceBox.

Constructor Detail

BaseChoiceBox

public BaseChoiceBox()
Construct a new ChoiceBox object.

Method Detail

getModel

public javax.swing.ComboBoxModel getModel()
Return the model for the ChoiceBox.

Returns:
The model for the ChoiceBox
See Also:
setModel(javax.swing.ComboBoxModel)

setModel

public void setModel(javax.swing.ComboBoxModel comboBoxModel)
Sets the model for the ChoiceBox.

Parameters:
comboBoxModel - The model for the ChoiceBox
See Also:
getModel()

setSelectedIndex

public void setSelectedIndex(int value)
                      throws java.io.IOException
Sets the index of single item to be marked as selected. Setting the index will set the corresponding selectedItem. By default the exception will not be thrown. To surface the exception, the setValidateSelection() method must be called passing the value of True.

Parameters:
index - The 0-based index of the item to be selected, or -1 for none
Throws:
java.lang.IllegalArgumentException - Thrown if index is out of bounds and setValidateSelection(true)
java.io.IOException
See Also:
setValidateSelection(boolean)

getSelectedIndex

public int getSelectedIndex()
Gets the index of single item to be marked as selected. If more than one index has been set this will return the last index set.

Returns:
The index of the selected value, or -1 for none

setSelectedItem

public void setSelectedItem(java.lang.String value)
                     throws java.io.IOException
Sets the value of a single item to be marked as selected. Setting the value will set the corresponding selectedIndex. Valid selectedItems correspond to the items in the model attribute. By default the exception will not be thrown. To surface the exception, the setValidateSelection() method must be called passing the value of True.

Parameters:
value - The value of the item to be selected
Throws:
java.lang.IllegalArgumentException - Thrown if item is not found and setValidateSelection(true)
java.io.IOException
See Also:
setValidateSelection(boolean)

setSelectedItem

public void setSelectedItem(java.lang.String value,
                            int defaultIndex)
Sets the value of a single item to be marked as selected. Setting the value will set the corresponding selectedIndex. Valid selectedItems correspond to the items in the model attribute. If the selectedItem does not exist, the defaultIndex will be used to set the selectedItem. If the defaultIndex does not exist, the selection will remain the same.

Parameters:
value - The value of the item to be selected
index - The 0-based index of the item to be selected, or -1 to remain the same, if selectedItem does not exist

getSelectedItem

public java.lang.String getSelectedItem()
Gets the value of a single item to be marked as selected.

Returns:
The selected value, or null for none

isSelected

protected boolean isSelected(int index)
Determines if the given index should be marked as selected

Parameters:
index - The index to check
Returns:
true if the index should be marked as selected

isSelected

protected boolean isSelected(java.lang.String value)
Determines if the given value should be marked as selected

Parameters:
value - The value to check
Returns:
true if the value should be marked as selected

setValidateSelection

public void setValidateSelection(boolean value)
Determines whether or not exceptions are thrown for setSelectedIndex() and setSelectedItem(). The default is false.

Parameters:
value - true if exceptions should be thrown for setSelectedIndex() and setSelectedItem()
See Also:
setSelectedIndex(int), setSelectedItem(java.lang.String)

isValidateSelection

public boolean isValidateSelection()
Returns whether or not exceptions are thrown for setSelectedIndex() and setSelectedItem().

Returns:
true if exceptions should be thrown for setSelectedIndex() and setSelectedItem()

getValueItemLabel

protected java.lang.String getValueItemLabel(com.sas.util.ValueItem item)



Copyright © 2009 SAS Institute Inc. All Rights Reserved.