com.arsdigita.bebop
Interface SingleSelectionModel

All Known Subinterfaces:
ComponentSelectionModel, DomainObjectSelectionModel, DomainObjectSelectionModel
All Known Implementing Classes:
AbstractSingleSelectionModel, ACSObjectSelectionModel, MapComponentSelectionModel, RequestLocalSelectionModel

public interface SingleSelectionModel

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.

Version:
$Id: //core-platform/dev/src/com/arsdigita/bebop/SingleSelectionModel.java#7 $
Author:
David Lutterkort

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

versionId

public static final String versionId
See Also:
Constant Field Values
Method Detail

isSelected

public boolean isSelected(PageState state)
Returns true if there is a selected element.

Parameters:
state - the state of the current request
Returns:
true if there is a selected component; false otherwise.

getSelectedKey

public Object getSelectedKey(PageState state)
Returns the key that identifies the selected element.

Parameters:
state - a PageState value
Returns:
a String value.

setSelectedKey

public void setSelectedKey(PageState state,
                           Object key)
Sets the selected key. If key is not in the collection of objects underlying this model, an IllegalArgumentException is thrown.

Parameters:
state - the state of the current request
key - the selected key
Throws:
IllegalArgumentException - if the supplied key can not be selected in the context of the current request.

clearSelection

public void clearSelection(PageState state)
Clears the selection.

Parameters:
state - the state of the current request

addChangeListener

public void addChangeListener(ChangeListener l)
Adds a change listener to the model. The listener's stateChanged method is called whenever the selected key changes.

Parameters:
l - a listener to notify when the selected key changes

removeChangeListener

public void removeChangeListener(ChangeListener l)
Removes a change listener from the model.

Parameters:
l - the listener to remove

getStateParameter

public ParameterModel getStateParameter()
Returns the state parameter that will be used to keep track of the currently selected key. Typically, the implementing class will simply call:
return new StringParameter("foo");

This method may return null if a state parameter is not appropriate in the context of the implementing class.

Returns:
the state parameter to use to keep track of the currently selected component, or null if a state parameter is not appropriate.


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC