|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.cms.ACSObjectSelectionModel
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.
Deprecated.
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 |
public ACSObjectSelectionModel(String javaClass, String objectType, String parameterName)
ACSObjectSelectionModel
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.public ACSObjectSelectionModel(String javaClass, String objectType, com.arsdigita.bebop.parameters.BigDecimalParameter parameter)
ACSObjectSelectionModel
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 IDpublic ACSObjectSelectionModel(String javaClass, String objectType, com.arsdigita.bebop.SingleSelectionModel model)
ACSObjectSelectionModel
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 objectMethod Detail |
public void setSelectedKey(com.arsdigita.bebop.PageState state, Object key)
setSelectedKey
in interface com.arsdigita.bebop.SingleSelectionModel
state
- The page statekey
- A BigDecimal
primary key for the object,
or a String representation of a BigDecimal, such as "42".public com.arsdigita.domain.DomainObject getSelectedObject(com.arsdigita.bebop.PageState state)
getSelectedObject
in interface DomainObjectSelectionModel
state
- The page state
public void setSelectedObject(com.arsdigita.bebop.PageState state, com.arsdigita.domain.DomainObject object)
setSelectedObject
in interface DomainObjectSelectionModel
state
- The page stateobject
- The content item to setpublic boolean isInitialized(com.arsdigita.bebop.PageState state)
state
- the page state
public com.arsdigita.kernel.ACSObject createACSObject(BigDecimal id) throws javax.servlet.ServletException
ACSObjectSelectionModel
.
id
- The id of the new item
javax.servlet.ServletException
public Class getJavaClass()
public String getObjectType()
public com.arsdigita.bebop.SingleSelectionModel getSingleSelectionModel()
SingleSelectionModel
which
maintains the ID of the selected objectpublic boolean isSelected(com.arsdigita.bebop.PageState state)
true
if there is a selected object.
isSelected
in interface com.arsdigita.bebop.SingleSelectionModel
state
- represents the state of the current request
true
if there is a selected component.public Object getSelectedKey(com.arsdigita.bebop.PageState state)
getSelectedKey
in interface com.arsdigita.bebop.SingleSelectionModel
state
- the current page state
BigDecimal
ID of the currently selected
object, or null if no object is selectedpublic void clearSelection(com.arsdigita.bebop.PageState state)
clearSelection
in interface com.arsdigita.bebop.SingleSelectionModel
state
- the current page state.public void addChangeListener(com.arsdigita.bebop.event.ChangeListener l)
stateChanged
is called whenever the selected key changes.
addChangeListener
in interface com.arsdigita.bebop.SingleSelectionModel
l
- a listener to notify when the selected key changespublic void removeChangeListener(com.arsdigita.bebop.event.ChangeListener l)
removeChangeListener
in interface com.arsdigita.bebop.SingleSelectionModel
l
- the listener to remove.public com.arsdigita.bebop.parameters.ParameterModel getStateParameter()
BigDecimalParameter
.
getStateParameter
in interface com.arsdigita.bebop.SingleSelectionModel
SingleSelectionModel.getStateParameter()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |