T - The Model Object typepublic abstract class LoadableDetachableModel<T> extends Object implements IModel<T>
getObject() 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 and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
void |
detach()
Detaches model after use.
|
T |
getObject()
Note: If
load() fails with an exception then null is kept as the attached
value. |
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() |
public LoadableDetachableModel()
public LoadableDetachableModel(T object)
object - retrieved instance of the detachable objectpublic void detach()
IDetachabledetach in interface IDetachableIDetachable.detach()public final T getObject()
load() fails with an exception then null is kept as the attached
value. Wicket 7.x improves this by staying detached instead, see WICKET-5772.getObject in interface IModel<T>IModel.getObject()public final boolean isAttached()
public String toString()
toString in class ObjectObject.toString()protected abstract T load()
protected void onAttach()
protected void onDetach()
Copyright © 2015–2017 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.