|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Model interface which holds a list of options and the selected item. This model can be used in a variety of ways. It can be used in an un-bound mode, where the current selection is maintained internally. It can also be used in a bound mode where the current selection is propagated to a value holder. When used in the bound mode, either a single property, or multiple properties can be set in the value holder.
The following sections describe the required settings to make for each of the modes.
Un-bound Mode
To use this component in the un-bound mode, you can set the following properties:
setDisplayPropertyName("locationName")
to display the zipCode. IMPORTANT - The displayed property choosen must
result in a unique list of values, otherwise the intended value may not be
selected/displayed.
To use this component in the bound mode, use the same properties as described in the Un-bound Mode, plus the following additional properties:
setPropertyName("zipCode")
to store the current selection in
the "Address.zipCode" property.
setPropertyNames(new String[] {"zipCode","city","state","country"})
setListPropertyNames(new String[] {"zipCode"})
. For
multiple properties use
setListPropertyNames(new String[] {"zipCode", "cityName", "stateAbbr",
"country"})
The List must be a CollectionValueHolder. The holder can contain any type of object (but they must all be instances of the same class).
The List can be any type of CollectionValueHolder such as VOCollectionValueHolder or VOListValueHolder.
If the List is an ObjectArrayValueHolderList, then the toString()
method is used as the display value (regardless of the displayPropertyName).
If used in the bound mode, the whole object itself is stored in the target
ValueHolder's object (regardless of the properties names listed in the
setListPropertyNames
method).
You can also preset the list in the constructor by passing it an array of Objects to be used for the List. The resulting List will be an ObjectArrayValueHolderList.
Other Important Information
When a selection is made, the values are copied from the properties in the list to the properties in the valueHolder object. The property names in propertyNames[] and listPropertyNames[] must appear in a corresponding order.
A "null" item will always be added to the listDisplay. When the "null" item is selected, a null will be assigned to the propertyNames[] in the valueHolder object. The actual "null" item to to display is defined by the nullDisplay (default is "--none--").
The format and pattern govern the display property in this component. The getText method returns the formatted display property, while the setText method changes the current selection to one whose display matches the given value. If you attempt to setText for an item that is not in the list, a NotInListException will be thrown.
Method Summary | |
java.util.Collection |
getDisplayOptionList()
Returns a Collection of the SelectModelOptions. |
java.lang.String |
getDisplayPropertyName()
Returns the property name of the list object to display in the list. |
CollectionValueHolder |
getList()
Returns collectionValueHolder which holds the collection of possible selections. |
java.lang.String[] |
getListPropertyNames()
Returns array of property names in list object to copy to valueHolder object. |
java.lang.String |
getNullDisplay()
Returns value to display in list for a null value. |
java.lang.String[] |
getPropertyNames()
Sets array of property names in valueHolder object that correspond to properties of list object. |
java.lang.Object |
getSelectedItem()
Returns the currently selected item from the list. |
boolean |
isNullAllowed()
Returns indicator that a null value is a valid selection. |
void |
setDisplayPropertyName(java.lang.String newDisplayPropertyName)
Sets the property name of the list object to display in the list. |
void |
setList(CollectionValueHolder newList)
Sets collectionValueHolder which holds the collection of possible selections. |
void |
setListPropertyNames(java.lang.String[] newListPropertyNames)
Sets array of property names in list object to copy to valueHolder object. |
void |
setNullAllowed(boolean newNullAllowed)
Sets indicator that a null value is a valid selection. |
void |
setNullDisplay(java.lang.String newNullDisplay)
Sets value to display in list for a null value. |
void |
setPropertyNames(java.lang.String[] newPropertyNames)
Sets array of property names in valueHolder object that correspond to properties of list object. |
void |
setSelectedItem(java.lang.Object value)
Sets the current selection by searching through the list for the given object. |
Methods inherited from interface com.taursys.model.TextModel |
addChangeListener, getFormat, getFormatPattern, getPropertyName, getText, getValueHolder, removeChangeListener, setFormat, setFormatPattern, setPropertyName, setText, setValueHolder |
Method Detail |
public java.util.Collection getDisplayOptionList() throws ModelException
The nullDisplay value will be first in the collection.
ModelException
- if problem while matching properties of valueHolder
object to list object.public java.lang.Object getSelectedItem() throws ModelException
NotInListException
- if current valueHolder object values do not
match any item in list.
ModelException
- if problem while matching properties of valueHolder
object to list object.public void setSelectedItem(java.lang.Object value) throws ModelException
NotInListException
- if the given value does not match any item in list.
ModelException
- if problem while setting properties of object in
valueHolder or fetching display values from the list.public void setList(CollectionValueHolder newList)
public CollectionValueHolder getList()
public void setDisplayPropertyName(java.lang.String newDisplayPropertyName)
public java.lang.String getDisplayPropertyName()
public void setListPropertyNames(java.lang.String[] newListPropertyNames)
public java.lang.String[] getListPropertyNames()
public void setPropertyNames(java.lang.String[] newPropertyNames)
public java.lang.String[] getPropertyNames()
public void setNullAllowed(boolean newNullAllowed)
nullDisplay
value will appear in the list of options
generated by getDisplayOptionList
and setText
will accept null or the nullDisplay
value. If false, the
setText
method will throw a NotInListException
if null or the nullDisplay
value is set, and the
nullDisplay
will not appear in the displayOptionList
.
Default is true.
public boolean isNullAllowed()
nullDisplay
value will appear in the list of options
generated by getDisplayOptionList
and setText
will accept null or the nullDisplay
value. If false, the
setText
method will throw a NotInListException
if null or the nullDisplay
value is set, and the
nullDisplay
will not appear in the displayOptionList
.
Default is true.
public void setNullDisplay(java.lang.String newNullDisplay)
public java.lang.String getNullDisplay()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |