com.sas.servlet.tbeans.form
Class BaseListBox

com.sas.servlet.tbeans.form.BaseListBox
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:
BaseListBoxView, ListBox

public abstract class BaseListBox

The BaseListBox is an abstract TransformationBean™ for creating a ListBox input field. A ListBox is a menu that allows either a single selection or multiple selections.

The ListBox TransformationBean™ gathers the selections from a model via the ListModel. A model must implement the javax.swing.ListModel 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:ListBox 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  javax.swing.ListModel model
          The model for the ListBox.
static java.lang.String RB_KEY
          Key used to lookup resources in the resource bundle.
 
Constructor Summary
BaseListBox()
          Construct a new ListBox
 
Method Summary
 javax.swing.ListModel getModel()
          Return the model for the ListBox.
 boolean getMultipleSelections()
          Gets the multiple selection attribute
 int getSelectedIndex()
          Gets the index of single item to be marked as selected.
 int[] getSelectedIndexes()
          Gets the array of index values of items to be marked as selected.
 java.lang.String getSelectedItem()
          Gets the value of a single item to be marked as selected.
 javax.swing.ListModel getSelectedItems()
          Gets the collection of values of items to be marked as selected.
 int getSize()
          Gets the size attribute
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.ListModel listModel)
          Sets the model for the ListBox.
 void setMultipleSelections(boolean value)
          Sets the multiple selection attribute allowing multiple selections of values in the list.
 void setSelectedIndex(int value)
          Sets the index of single item to be marked as selected.
 void setSelectedIndexes(int[] value)
          Sets an array of index values for items 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 setSelectedItems(javax.swing.ListModel values)
          Sets a collection of values of items to be marked as selected.
 void setSelectedItems(javax.swing.ListModel values, int defaultIndex)
          Sets a collection of values of items to be marked as selected.
 void setSize(int value)
          Sets the size attribute.
 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

model

protected javax.swing.ListModel model
The model for the ListBox.

Constructor Detail

BaseListBox

public BaseListBox()
Construct a new ListBox

Method Detail

getModel

public javax.swing.ListModel getModel()
Return the model for the ListBox.

Returns:
the model for the ListBox
See Also:
setModel(javax.swing.ListModel)

setModel

public void setModel(javax.swing.ListModel listModel)
Sets the model for the ListBox.

Parameters:
listModel - the model for the ListBox
See Also:
getModel()

setSize

public void setSize(int value)
Sets the size attribute. The default value is 4.

Parameters:
size - The maximum number of values visible to the user

getSize

public int getSize()
Gets the size attribute

Returns:
The maximum number of values visible to the user

setMultipleSelections

public void setMultipleSelections(boolean value)
Sets the multiple selection attribute allowing multiple selections of values in the list. The default is false.

Parameters:
multiple - true if multiple selections are allowed

getMultipleSelections

public boolean getMultipleSelections()
Gets the multiple selection attribute

Returns:
true if multiple selections are allowed

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 also update 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)

setSelectedIndexes

public void setSelectedIndexes(int[] value)
                        throws java.io.IOException
Sets an array of index values for items to be marked as selected. Setting the index will also update the corresponding selectedItems. By default the exception will not be thrown. To surface the exception, the setValidateSelection() method must be called passing the value of True.

Parameters:
indexArray - An array of 0-based index values for items to be selected
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 a -1.

Returns:
The array of 0-based values, or null for none

getSelectedIndexes

public int[] getSelectedIndexes()
Gets the array of index values of items to be marked as selected. If only a single index has been set this will return a single element array with the value.

Returns:
The array of 0-based values, or null 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 also 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

setSelectedItems

public void setSelectedItems(javax.swing.ListModel values)
                      throws java.io.IOException
Sets a collection of values of items to be marked as selected. Setting the value will also set the corresponding selectedIndexes. Valid selectedItems correspond to the items in the model attribute.

Parameters:
values - The collection of values to be marked as selected
Throws:
java.lang.IllegalArgumentException - Thrown if item is not found and setValidateSelection(true)
java.io.IOException

setSelectedItems

public void setSelectedItems(javax.swing.ListModel values,
                             int defaultIndex)
Sets a collection of values of items to be marked as selected. Setting the value will also set the corresponding selectedIndexes. Valid selectedItems correspond to the items in the model attribute.

Parameters:
values - The collection of values to be marked as 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. If more than one value has been set this will return a blank string

Returns:
The collection of selected values, or null for none

getSelectedItems

public javax.swing.ListModel getSelectedItems()
Gets the collection of values of items to be marked as selected. If only a single value has been set this will return only one element

Returns:
The collection of selected values, 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()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.