|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Encapsulates the selection of a single object from many
possibilities. The SingleSelectionModel
allows components to
communicate selections without tying the component that manages the
selection in the user interface (for example a List
) to the
components that consume the selection (such as an edit form that needs
to know which object should be edited).
Selections are identified by a key, which must identify the
underlying object uniquely among all objects that could possibly be
selected. For objects stored in a database, this is usually a suitable
representation of the object's primary key. The model relies on the
key's equals
method to compare keys, and requires that the
key's toString
method produces a representation of the key
that can be used in URL strings and hidden form controls.
Field Summary | |
static String |
versionId
|
Method Summary | |
void |
addChangeListener(ChangeListener l)
Adds a change listener to the model. |
void |
clearSelection(PageState state)
Clears the selection. |
Object |
getSelectedKey(PageState state)
Returns the key that identifies the selected element. |
ParameterModel |
getStateParameter()
Returns the state parameter that will be used to keep track of the currently selected key. |
boolean |
isSelected(PageState state)
Returns true if there is a selected element. |
void |
removeChangeListener(ChangeListener l)
Removes a change listener from the model. |
void |
setSelectedKey(PageState state,
Object key)
Sets the selected key. |
Field Detail |
public static final String versionId
Method Detail |
public boolean isSelected(PageState state)
true
if there is a selected element.
state
- the state of the current request
true
if there is a selected component;
false
otherwise.public Object getSelectedKey(PageState state)
state
- a PageState
value
String
value.public void setSelectedKey(PageState state, Object key)
key
is not in the collection of
objects underlying this model, an
IllegalArgumentException
is thrown.
state
- the state of the current requestkey
- the selected key
IllegalArgumentException
- if the supplied key
can not
be selected in the context of the current request.public void clearSelection(PageState state)
state
- the state of the current requestpublic void addChangeListener(ChangeListener l)
stateChanged
method is called whenever the selected key changes.
l
- a listener to notify when the selected key changespublic void removeChangeListener(ChangeListener l)
l
- the listener to removepublic ParameterModel getStateParameter()
return new StringParameter("foo");
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |