|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.wicket.model.AbstractReadOnlyModel<T>
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 AbstractReadOnlyModel.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. |
java.lang.String |
toString()
|
Methods inherited from class org.apache.wicket.model.AbstractReadOnlyModel |
---|
getObject, setObject |
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
detach
in class AbstractReadOnlyModel<T>
IDetachable.detach()
public T getObject()
IModel
getObject
in interface IModel<T>
getObject
in class AbstractReadOnlyModel<T>
IModel.getObject()
public final boolean isAttached()
public java.lang.String toString()
toString
in class AbstractReadOnlyModel<T>
Object.toString()
protected abstract T load()
protected void onAttach()
protected void onDetach()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |