com.arsdigita.cms
Class ACSObjectSelectionModel

java.lang.Object
  extended bycom.arsdigita.cms.ACSObjectSelectionModel
All Implemented Interfaces:
DomainObjectSelectionModel, com.arsdigita.bebop.SingleSelectionModel

Deprecated. Use ACSObjectSelectionModel

Loads a subclass of an ACSObject from the database. By default, uses a BigDecimal state parameter in order to store and retrieve the item ID.

The getSelectedKey(PageState state) method will return the BigDecimal ID of the currently selected object. This method will return the ID even if the object with this ID does not actually exist.

The getSelectedObject(PageState state) method will return the object whose ID is getSelectedKey(PageState state). If the object does not actually exist, the method will return null.

Thus, it is possible to implement the following pattern:

ACSObjectSelectionModel model = new ACSObjectSelectionModel(....);
 // ....
 ACSObject obj;
 if(model.isSelected(state)) {
   obj = (ACSObject) model.getSelectedObject(state);
   if (obj == null) {
     // Create a new object
     obj = model.createObject(model.getSelectedKey(state));
     model.setSelectedObject(state, obj);
   }
 }

The createObject method is merely a convenience method for instantiating the right subclass of ACSObject.

Advanced Usage: The ACSObjectSelectionModel is actually just a wrapper for a SingleSelectionModel which maintains the currently selected object's ID as a BigDecimal. By default, a new ParameterSingleSelectionModel is wrapped in this way; however, any SingleSelectionModel may be wrapped. Thus, it becomes possible to use the ACSObjectSelectionModel even if the currently selected ID is not stored in a state parameter.

public class ACSObjectSelectionModel
extends Object
implements DomainObjectSelectionModel

Deprecated.

Version:
$Id: //cms/dev/src/com/arsdigita/cms/ACSObjectSelectionModel.java#12 $
Author:
Stanislav Freidin
See Also:
SingleSelectionModel, ParameterSingleSelectionModel

Field Summary
 
Fields inherited from interface com.arsdigita.cms.DomainObjectSelectionModel
versionId
 
Constructor Summary
ACSObjectSelectionModel(String javaClass, String objectType, com.arsdigita.bebop.parameters.BigDecimalParameter parameter)
          Deprecated. Construct a new ACSObjectSelectionModel
ACSObjectSelectionModel(String javaClass, String objectType, com.arsdigita.bebop.SingleSelectionModel model)
          Deprecated.  
ACSObjectSelectionModel(String javaClass, String objectType, String parameterName)
          Deprecated.  
 
Method Summary
 void addChangeListener(com.arsdigita.bebop.event.ChangeListener l)
          Deprecated.  
 void clearSelection(com.arsdigita.bebop.PageState state)
          Deprecated.  
 com.arsdigita.kernel.ACSObject createACSObject(BigDecimal id)
          Deprecated.  
 Class getJavaClass()
          Deprecated.  
 String getObjectType()
          Deprecated.  
 Object getSelectedKey(com.arsdigita.bebop.PageState state)
          Deprecated.  
 com.arsdigita.domain.DomainObject getSelectedObject(com.arsdigita.bebop.PageState state)
          Deprecated.  
 com.arsdigita.bebop.SingleSelectionModel getSingleSelectionModel()
          Deprecated.  
 com.arsdigita.bebop.parameters.ParameterModel getStateParameter()
          Deprecated.  
 boolean isInitialized(com.arsdigita.bebop.PageState state)
          Deprecated.  
 boolean isSelected(com.arsdigita.bebop.PageState state)
          Deprecated.  
 void removeChangeListener(com.arsdigita.bebop.event.ChangeListener l)
          Deprecated.  
 void setSelectedKey(com.arsdigita.bebop.PageState state, Object key)
          Deprecated.  
 void setSelectedObject(com.arsdigita.bebop.PageState state, com.arsdigita.domain.DomainObject object)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ACSObjectSelectionModel

public ACSObjectSelectionModel(String javaClass,
                               String objectType,
                               String parameterName)
Deprecated.  

Construct a new ACSObjectSelectionModel

Parameters:
javaClass - The name of the Java class which represents the object. Must be a subclass of ACSObject. In addition, the class must have a constructor with a single OID parameter.
objectType - The name of the persistence metadata object type which represents the ACS object. In practice, will often be the same as the javaClass.
parameterName - The name of the state parameter which will be used to store the object ID.

ACSObjectSelectionModel

public ACSObjectSelectionModel(String javaClass,
                               String objectType,
                               com.arsdigita.bebop.parameters.BigDecimalParameter parameter)
Deprecated. 
Construct a new ACSObjectSelectionModel

Parameters:
javaClass - The name of the Java class which represents the object. Must be a subclass of ACSObject. In addition, the class must have a constructor with a single OID parameter.
objectType - The name of the persistence metadata object type which represents the ACS object. In practice, will often be the same as the javaClass.
parameter - The state parameter which should be used to store the object ID

ACSObjectSelectionModel

public ACSObjectSelectionModel(String javaClass,
                               String objectType,
                               com.arsdigita.bebop.SingleSelectionModel model)
Deprecated.  

Construct a new ACSObjectSelectionModel

Parameters:
javaClass - The name of the Java class which represents the object. Must be a subclass of ACSObject. In addition, the class must have a constructor with a single OID parameter.
objectType - The name of the persistence metadata object type which represents the ACS object. In practice, will often be the same as the javaClass.
model - The SingleSelectionModel which will supply a BigDecimal ID of the currently selected object
Method Detail

setSelectedKey

public void setSelectedKey(com.arsdigita.bebop.PageState state,
                           Object key)
Deprecated.  

Set the ID of the current object

Specified by:
setSelectedKey in interface com.arsdigita.bebop.SingleSelectionModel
Parameters:
state - The page state
key - A BigDecimal primary key for the object, or a String representation of a BigDecimal, such as "42".

getSelectedObject

public com.arsdigita.domain.DomainObject getSelectedObject(com.arsdigita.bebop.PageState state)
Deprecated.  

Return the object which was selected and loaded from the database, using the values supplied in the page state. May return null if no object was selected, or if the item was not found.

Specified by:
getSelectedObject in interface DomainObjectSelectionModel
Parameters:
state - The page state
Returns:
The item domain object, or null if no item is selected.

setSelectedObject

public void setSelectedObject(com.arsdigita.bebop.PageState state,
                              com.arsdigita.domain.DomainObject object)
Deprecated.  

Select the specified object.

Specified by:
setSelectedObject in interface DomainObjectSelectionModel
Parameters:
state - The page state
object - The content item to set

isInitialized

public boolean isInitialized(com.arsdigita.bebop.PageState state)
Deprecated.  

Determine if the attempt to load the selected object has been made yet. Child classes may use this method to perform request-local initialization.

Parameters:
state - the page state
Returns:
true if the attempt to load the selected object has already been made, false otherwise

createACSObject

public com.arsdigita.kernel.ACSObject createACSObject(BigDecimal id)
                                               throws javax.servlet.ServletException
Deprecated.  

A utility function which creates a new object with the given ID. Uses reflection to create the instance of the class supplied in the constructor to this ACSObjectSelectionModel.

Parameters:
id - The id of the new item
Returns:
The newly created item
Throws:
javax.servlet.ServletException

getJavaClass

public Class getJavaClass()
Deprecated.  

Returns:
the Class of the content items which are produced by this model

getObjectType

public String getObjectType()
Deprecated.  

Returns:
The name of the object type of the content items which are produced by this model

getSingleSelectionModel

public com.arsdigita.bebop.SingleSelectionModel getSingleSelectionModel()
Deprecated.  

Returns:
the underlying SingleSelectionModel which maintains the ID of the selected object

isSelected

public boolean isSelected(com.arsdigita.bebop.PageState state)
Deprecated.  

Return true if there is a selected object.

Specified by:
isSelected in interface com.arsdigita.bebop.SingleSelectionModel
Parameters:
state - represents the state of the current request
Returns:
true if there is a selected component.

getSelectedKey

public Object getSelectedKey(com.arsdigita.bebop.PageState state)
Deprecated.  

Return the key that identifies the selected object.

Specified by:
getSelectedKey in interface com.arsdigita.bebop.SingleSelectionModel
Parameters:
state - the current page state
Returns:
the BigDecimal ID of the currently selected object, or null if no object is selected

clearSelection

public void clearSelection(com.arsdigita.bebop.PageState state)
Deprecated.  

Clear the selection.

Specified by:
clearSelection in interface com.arsdigita.bebop.SingleSelectionModel
Parameters:
state - the current page state.

addChangeListener

public void addChangeListener(com.arsdigita.bebop.event.ChangeListener l)
Deprecated.  

Add a change listener to the model. The listener's stateChanged is called whenever the selected key changes.

Specified by:
addChangeListener in interface com.arsdigita.bebop.SingleSelectionModel
Parameters:
l - a listener to notify when the selected key changes

removeChangeListener

public void removeChangeListener(com.arsdigita.bebop.event.ChangeListener l)
Deprecated.  

Remove a change listener from the model.

Specified by:
removeChangeListener in interface com.arsdigita.bebop.SingleSelectionModel
Parameters:
l - the listener to remove.

getStateParameter

public com.arsdigita.bebop.parameters.ParameterModel getStateParameter()
Deprecated.  

Return the state parameter which will be used to keep track of the currently selected key. Most likely, the parameter will be a BigDecimalParameter.

Specified by:
getStateParameter in interface com.arsdigita.bebop.SingleSelectionModel
Returns:
The state parameter which should be used to keep track of the ID of the currently selected object, or null if the ID is computed in some other way
See Also:
SingleSelectionModel.getStateParameter()


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