com.arsdigita.bebop
Class ParameterSingleSelectionModel

java.lang.Object
  extended bycom.arsdigita.bebop.AbstractSingleSelectionModel
      extended bycom.arsdigita.bebop.ParameterSingleSelectionModel
All Implemented Interfaces:
Lockable, SingleSelectionModel
Direct Known Subclasses:
Tree.TreeSingleSelectionModel

public class ParameterSingleSelectionModel
extends AbstractSingleSelectionModel

An implementation of SingleSelectionModel that uses a state parameter for managing the currently selected key.

A typical use case for this class is as follows.

public TheConstructor() {
   m_parameter = new StringParameter("my_key");
   m_sel = new ParameterSingleSelectionModel(m_parameter);
 }

 public void register(Page p) {
   p.addComponent(this);
   p.addComponentStateParam(this, m_param);
 }

Author:
Stanislav Freidin

Field Summary
static String versionId
           
 
Constructor Summary
ParameterSingleSelectionModel(ParameterModel m)
          Constructs a new ParameterSingleSelectionModel.
 
Method Summary
 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.
 void setSelectedKey(PageState state, Object newKey)
          Set the selected key.
 
Methods inherited from class com.arsdigita.bebop.AbstractSingleSelectionModel
addChangeListener, clearSelection, fireStateChanged, isLocked, isSelected, lock, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

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

ParameterSingleSelectionModel

public ParameterSingleSelectionModel(ParameterModel m)
Constructs a new ParameterSingleSelectionModel.

Parameters:
m - the parameter model that will be used to keep track of the currently selected key
Method Detail

getSelectedKey

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

Specified by:
getSelectedKey in interface SingleSelectionModel
Specified by:
getSelectedKey in class AbstractSingleSelectionModel
Parameters:
state - a PageState value
Returns:
a String value.

getStateParameter

public final ParameterModel getStateParameter()
Description copied from interface: SingleSelectionModel
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.

setSelectedKey

public void setSelectedKey(PageState state,
                           Object newKey)
Set the selected key.

Specified by:
setSelectedKey in interface SingleSelectionModel
Specified by:
setSelectedKey in class AbstractSingleSelectionModel
Parameters:
state - represents the state of the current request
newKey - the new selected key


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