|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.model.LoadableDetachableModel<T>
T
- The Model Object typepublic abstract class LoadableDetachableModel<T>
Model that makes working with detachable models a breeze. LoadableDetachableModel holds a
temporary, transient model object, that is set when #getObject(Component)
is called by
calling abstract method 'load', and that will be reset/ set to null on detach()
.
A usage example:
LoadableDetachableModel venueListModel = new LoadableDetachableModel() { protected Object load() { return getVenueDao().findVenues(); } };
Though you can override methods onAttach()
and onDetach()
for additional
attach/ detach behavior, the point of this class is to hide as much of the attaching/ detaching
as possible. So you should rarely need to override those methods, if ever.
Constructor Summary | |
---|---|
LoadableDetachableModel()
Construct. |
|
LoadableDetachableModel(T object)
This constructor is used if you already have the object retrieved and want to wrap it with a detachable model. |
Method Summary | |
---|---|
void |
detach()
Detaches model after use. |
T |
getObject()
Gets the model object. |
boolean |
isAttached()
Gets the attached status of this model instance |
protected abstract T |
load()
Loads and returns the (temporary) model object. |
protected void |
onAttach()
Attaches to the current request. |
protected void |
onDetach()
Detaches from the current request. |
void |
setObject(T object)
Manually loads the model with the specified object. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public LoadableDetachableModel()
public LoadableDetachableModel(T object)
object
- retrieved instance of the detachable objectMethod Detail |
---|
public void detach()
IDetachable
detach
in interface IDetachable
IDetachable.detach()
public T getObject()
IModel
getObject
in interface IModel<T>
IModel.getObject()
public final boolean isAttached()
public String toString()
toString
in class Object
Object.toString()
protected abstract T load()
protected void onAttach()
protected void onDetach()
public void setObject(T object)
getObject()
will return object
until detach()
is called.
setObject
in interface IModel<T>
object
- The object to set into the model
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |