public abstract class AbstractJsonAdapter<T> extends Object implements IJsonAdapter<T>
Constructor and Description |
---|
AbstractJsonAdapter(T model,
IUiSession uiSession,
String id,
IJsonAdapter<?> parent) |
Modifier and Type | Method and Description |
---|---|
protected JsonEvent |
addActionEvent(String eventName) |
protected JsonEvent |
addActionEvent(String eventName,
IJsonAdapter<?> referenceAdapter,
JSONObject eventData) |
protected JsonEvent |
addActionEvent(String eventName,
JSONObject eventData) |
protected JsonEvent |
addPropertyChangeEvent(String propertyName,
Object newValue) |
<A extends IJsonAdapter<M>,M> |
attachAdapter(M model) |
<A extends IJsonAdapter<M>,M> |
attachAdapter(M model,
Predicate<M> filter) |
<M> List<IJsonAdapter<?>> |
attachAdapters(Collection<M> models) |
<M> List<IJsonAdapter<?>> |
attachAdapters(Collection<M> models,
Predicate<M> filter) |
protected void |
attachChildAdapters()
Attach child adapters of this adapter instance here by calling the
attachAdapter[s](model[s]) methods. |
protected <A extends IJsonAdapter<M>,M> |
attachGlobalAdapter(M model)
A global adapter is registered under the root json adapter and may be used by other adapters.
|
protected <A extends IJsonAdapter<M>,M> |
attachGlobalAdapter(M model,
Predicate<M> filter) |
protected <M> List<IJsonAdapter<?>> |
attachGlobalAdapters(Collection<M> models) |
protected <M> List<IJsonAdapter<?>> |
attachGlobalAdapters(Collection<M> models,
Predicate<M> filter) |
protected void |
attachModel()
Override this method in order to attach listeners on the Scout model object.
|
void |
cleanUpEventFilters()
An adapter may clean up it's event filters when this method is called after an UI event has been processed.
|
protected void |
detachModel() |
void |
dispose() |
protected void |
disposeChildAdapters() |
<A extends IJsonAdapter<M>,M> |
getAdapter(M model)
Returns an existing adapter for the given model.
|
<A extends IJsonAdapter<M>,M> |
getAdapter(M model,
Predicate<M> filter) |
Collection<IJsonAdapter<?>> |
getAdapters(Collection<?> models) |
<M> Collection<IJsonAdapter<?>> |
getAdapters(Collection<M> models,
Predicate<M> filter) |
<A extends IJsonAdapter<M>,M> |
getGlobalAdapter(M model) |
<A extends IJsonAdapter<M>,M> |
getGlobalAdapter(M model,
Predicate<M> filter) |
String |
getId() |
T |
getModel()
Returns the Scout model object.
|
protected String |
getObjectTypeVariant()
Returns a string used to identify the object-type in the JSON output (JSON attribute 'objectType').
|
IJsonAdapter<?> |
getParent() |
IUiSession |
getUiSession() |
void |
handleUiEvent(JsonEvent event) |
protected void |
handleUiPropertyChange(JsonEvent event) |
protected void |
handleUiPropertyChange(String propertyName,
JSONObject data)
Override this method to handle property changes from the UI.
|
boolean |
hasAncestor(IJsonAdapter<?> ancestor) |
void |
init()
Init method which is called by the factory after the constructor has been executed.
|
boolean |
isDisposed() |
boolean |
isInitialized() |
void |
processBufferedEvents()
Consumes all buffered model events, if there are any.
|
protected <M> JSONObject |
putAdapterIdProperty(JSONObject json,
String key,
M model) |
protected <M> JSONObject |
putAdapterIdProperty(JSONObject json,
String key,
M model,
Predicate<M> filter) |
protected <M> JSONObject |
putAdapterIdsProperty(JSONObject json,
String key,
Collection<M> models) |
protected <M> JSONObject |
putAdapterIdsProperty(JSONObject json,
String key,
Collection<M> models,
Predicate<M> filter) |
protected JSONObject |
putProperty(JSONObject json,
String key,
Object value) |
protected void |
registerAsBufferedEventsAdapter() |
protected JsonEvent |
replaceActionEvent(String eventName,
JSONObject eventData)
Like
addActionEvent(String, JSONObject) but if there are already action events for the same event in the
current response, all existing events are removed before adding the new event. |
JSONObject |
toJson() |
String |
toString() |
protected void |
unregisterAsBufferedEventsAdapter() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getObjectType
public AbstractJsonAdapter(T model, IUiSession uiSession, String id, IJsonAdapter<?> parent)
public final String getId()
getId
in interface IJsonAdapter<T>
public IUiSession getUiSession()
getUiSession
in interface IJsonAdapter<T>
public IJsonAdapter<?> getParent()
getParent
in interface IJsonAdapter<T>
public boolean hasAncestor(IJsonAdapter<?> ancestor)
hasAncestor
in interface IJsonAdapter<T>
public T getModel()
IJsonAdapter
getModel
in interface IJsonAdapter<T>
protected void attachChildAdapters()
attachAdapter[s](model[s])
methods.
This will also create a new JSON adapter instance when the adapter does not yet exist for the given model.protected void disposeChildAdapters()
public void init()
IJsonAdapter
attachModel()
and attachChildAdapters()
.init
in interface IJsonAdapter<T>
protected void attachModel()
public final void dispose()
dispose
in interface IJsonAdapter<T>
protected void detachModel()
public boolean isDisposed()
isDisposed
in interface IJsonAdapter<T>
public boolean isInitialized()
isInitialized
in interface IJsonAdapter<T>
public JSONObject toJson()
toJson
in interface IJsonAdapter<T>
toJson
in interface IJsonObject
protected String getObjectTypeVariant()
IJsonAdapter.getObjectType()
, this method returns the object type including the model variant (if set). The
resulting string looks like this: "<ObjectType>.<ModelVariant>"
.ModelVariant
public void handleUiEvent(JsonEvent event)
handleUiEvent
in interface IJsonAdapter<T>
protected void handleUiPropertyChange(JsonEvent event)
protected void handleUiPropertyChange(String propertyName, JSONObject data)
public final <A extends IJsonAdapter<M>,M> A attachAdapter(M model)
public final <A extends IJsonAdapter<M>,M> A attachAdapter(M model, Predicate<M> filter)
attachAdapter
in interface IJsonAdapter<T>
public final <M> List<IJsonAdapter<?>> attachAdapters(Collection<M> models)
attachAdapters
in interface IJsonAdapter<T>
public final <M> List<IJsonAdapter<?>> attachAdapters(Collection<M> models, Predicate<M> filter)
attachAdapters
in interface IJsonAdapter<T>
public final <A extends IJsonAdapter<M>,M> A getAdapter(M model)
getUiSession().getJsonAdapter(model)
.getAdapter
in interface IJsonAdapter<T>
public <A extends IJsonAdapter<M>,M> A getAdapter(M model, Predicate<M> filter)
getAdapter
in interface IJsonAdapter<T>
public final Collection<IJsonAdapter<?>> getAdapters(Collection<?> models)
getAdapters
in interface IJsonAdapter<T>
public <M> Collection<IJsonAdapter<?>> getAdapters(Collection<M> models, Predicate<M> filter)
getAdapters
in interface IJsonAdapter<T>
public final <A extends IJsonAdapter<M>,M> A getGlobalAdapter(M model)
public final <A extends IJsonAdapter<M>,M> A getGlobalAdapter(M model, Predicate<M> filter)
protected final <M> List<IJsonAdapter<?>> attachGlobalAdapters(Collection<M> models)
protected final <M> List<IJsonAdapter<?>> attachGlobalAdapters(Collection<M> models, Predicate<M> filter)
protected final <A extends IJsonAdapter<M>,M> A attachGlobalAdapter(M model)
Rule: Always create a global adapter if the model is able to dispose itself (Form, MessageBox, etc). In every other case you have to be very careful. If you dispose a global adapter it may influence others which are using it.
Global adapters (like every other) get disposed on session disposal.
protected final <A extends IJsonAdapter<M>,M> A attachGlobalAdapter(M model, Predicate<M> filter)
protected final <M> JSONObject putAdapterIdProperty(JSONObject json, String key, M model)
protected final <M> JSONObject putAdapterIdProperty(JSONObject json, String key, M model, Predicate<M> filter)
protected final <M> JSONObject putAdapterIdsProperty(JSONObject json, String key, Collection<M> models)
protected final <M> JSONObject putAdapterIdsProperty(JSONObject json, String key, Collection<M> models, Predicate<M> filter)
protected final JSONObject putProperty(JSONObject json, String key, Object value)
protected final JsonEvent addActionEvent(String eventName, JSONObject eventData)
protected final JsonEvent addActionEvent(String eventName, IJsonAdapter<?> referenceAdapter, JSONObject eventData)
protected final void registerAsBufferedEventsAdapter()
protected final void unregisterAsBufferedEventsAdapter()
protected final JsonEvent replaceActionEvent(String eventName, JSONObject eventData)
addActionEvent(String, JSONObject)
but if there are already action events for the same event in the
current response, all existing events are removed before adding the new event.protected JsonEvent addPropertyChangeEvent(String propertyName, Object newValue)
public void cleanUpEventFilters()
IJsonAdapter
cleanUpEventFilters
in interface IJsonAdapter<T>
public void processBufferedEvents()
IJsonAdapter
processBufferedEvents
in interface IJsonAdapter<T>
Copyright © 2014–2021. All rights reserved.