wicket.model
Class LoadableDetachableModel

java.lang.Object
  extended bywicket.model.AbstractDetachableModel
      extended bywicket.model.LoadableDetachableModel
All Implemented Interfaces:
IDetachable, IModel, java.io.Serializable

public abstract class LoadableDetachableModel
extends AbstractDetachableModel

Model that makes working with detachable models a breeze. LoadableDetachableModel holds a temporary, transient model object, that is set on 'onAttach' by calling abstract method 'load', and that will be reset/ set to null on 'onDetach'. A usage example:

 LoadableDetachableModel venueListModel = new LoadableDetachableModel()
 {
   protected Object load()
   {
      return getVenueDao().findVenues();
   }	
 };
 

Author:
Eelco Hillenius
See Also:
Serialized Form

Constructor Summary
LoadableDetachableModel()
          Construct.
 
Method Summary
 IModel getNestedModel()
          Gets the nested model.
protected abstract  java.lang.Object load()
          Loads and returns the (temporary) model object.
protected  void onAttach()
          Attaches to the current request.
protected  void onDetach()
          Detaches from the current request.
protected  java.lang.Object onGetObject(Component component)
          Called when getObject is called in order to retrieve the detachable object.
protected  void onSetObject(Component component, java.lang.Object object)
          Called when setObject is called in order to change the detachable object.
protected  void setObject(java.lang.Object object)
          Sets the object.
 
Methods inherited from class wicket.model.AbstractDetachableModel
attach, detach, getObject, isAttached, setObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoadableDetachableModel

public LoadableDetachableModel()
Construct.

Method Detail

onAttach

protected final void onAttach()
Description copied from class: AbstractDetachableModel
Attaches to the current request. Implement this method with custom behaviour, such as loading the model object.

Specified by:
onAttach in class AbstractDetachableModel
See Also:
AbstractDetachableModel.onAttach()

load

protected abstract java.lang.Object load()
Loads and returns the (temporary) model object.

Returns:
the (temporary) model object

onDetach

protected final void onDetach()
Description copied from class: AbstractDetachableModel
Detaches from the current request. Implement this method with custom behaviour, such as setting the model object to null.

Specified by:
onDetach in class AbstractDetachableModel
See Also:
AbstractDetachableModel.onDetach()

onGetObject

protected final java.lang.Object onGetObject(Component component)
Description copied from class: AbstractDetachableModel
Called when getObject is called in order to retrieve the detachable object. Before this method is called, getObject() always calls attach() to ensure that the object is attached.

Specified by:
onGetObject in class AbstractDetachableModel
Parameters:
component - The component asking for the object
Returns:
The object
See Also:
AbstractDetachableModel.onGetObject(wicket.Component)

setObject

protected final void setObject(java.lang.Object object)
Sets the object.

Parameters:
object - the object

onSetObject

protected final void onSetObject(Component component,
                                 java.lang.Object object)
Description copied from class: AbstractDetachableModel
Called when setObject is called in order to change the detachable object. Before this method is called, setObject() always calls attach() to ensure that the object is attached.

Specified by:
onSetObject in class AbstractDetachableModel
Parameters:
component - The component asking for replacement of the model object
object - The new model object
See Also:
AbstractDetachableModel.onSetObject(wicket.Component, java.lang.Object)

getNestedModel

public final IModel getNestedModel()
Description copied from interface: IModel
Gets the nested model.

Specified by:
getNestedModel in interface IModel
Specified by:
getNestedModel in class AbstractDetachableModel
See Also:
IModel.getNestedModel()


Copyright © 2004-2005 Wicket developers. All Rights Reserved.