T - The Model Object typepublic abstract class LoadableDetachableModel<T> extends Object implements de.alpharogroup.model.api.Model<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(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() |
T |
getObject() |
boolean |
isAttached()
Checks if the object is attached.
|
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(T object)
object - retrieved instance of the detachable objectpublic void detach()
detach in interface de.alpharogroup.model.api.Detachablepublic final T getObject()
getObject in interface de.alpharogroup.model.api.Model<T>public final boolean isAttached()
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 de.alpharogroup.model.api.Model<T>object - The object to set into the modelCopyright © 2015–2017 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.