A
- The type of the action.R
- The type of the result.public abstract class AbstractCachingClientActionHandler<A,R> extends AbstractClientActionHandler<A,R>
Supported features include:
prefetch(A)
/postfetch(A, R)
perform the cache lookup and the cache store. You can use this to customize
the caching logic.
Constructor and Description |
---|
AbstractCachingClientActionHandler(Class<A> actionType,
Cache cache) |
Modifier and Type | Method and Description |
---|---|
DispatchRequest |
execute(A action,
AsyncCallback<R> resultCallback,
ExecuteCommand<A,R> executeCommand)
Handles the specified action.
|
protected Cache |
getCache() |
protected abstract void |
postfetch(A action,
R result)
Override this method to perform an action after the call to the server returns successfully or not.
|
protected abstract R |
prefetch(A action)
Override this method to perform an action before the call is sent to the server.
|
DispatchRequest |
undo(A action,
R result,
AsyncCallback<Void> callback,
UndoCommand<A,R> undoCommand)
Undoes the specified action if supported.
|
getActionType
public DispatchRequest execute(A action, AsyncCallback<R> resultCallback, ExecuteCommand<A,R> executeCommand)
ClientActionHandler
com.gwtplatform.dispatch.client.DelegatingDispatchRequest#isCancelled()
against the request parameter.action
- The action to execute.resultCallback
- The callback to use to communicate the result of the action. Unless the request is
cancelled, you must invoke AsyncCallback.onSuccess(T)
on this callback once you have
obtained the result. If any failure occurs call AsyncCallback.onFailure(java.lang.Throwable)
.executeCommand
- Call ExecuteCommand.execute(Object, com.google.gwt.user.client.rpc.AsyncCallback)
on this object to send the action over to the server.
As a parameter you can pass resultCallback
or your custom AsyncCallback
if
you want to process the result.DispatchRequest
object. Never return null
, instead return a new
CompletedDispatchRequest
if you executed,
cancelled or ignored the action.public DispatchRequest undo(A action, R result, AsyncCallback<Void> callback, UndoCommand<A,R> undoCommand)
ClientActionHandler
com.gwtplatform.dispatch.client.DelegatingDispatchRequest#isCancelled()
against the request parameter.action
- The action to undo.result
- The result to undo.callback
- The callback to use to indicate when the action has been undone. Unless the request is
cancelled, you must invoke AsyncCallback.onSuccess(T)
on this callback when you have
successfully undone the action. If any failure occurs call AsyncCallback.onFailure(java.lang.Throwable)
.undoCommand
- Call UndoCommand.undo(Object, Object, com.google.gwt.user.client.rpc.AsyncCallback)
on
this object to send the action over to the server via gwt-rpc. As a parameter you can pass
callback
or your custom AsyncCallback
if you want to perform any processing
following the undo.DispatchRequest
object. Never return null
, instead return a new
CompletedDispatchRequest
if you executed,
cancelled or ignored the action.protected abstract R prefetch(A action)
null
result then the action is never executed on the server and the returned value is used. If the
call returns null
then the action is executed on the server.
You can use this method to fetch the action
from the cache.action
- The action to be prefetchednull
.protected abstract void postfetch(A action, R result)
null
will be passed in the result
parameter.
You can use this method to add the result to cache, if it is null
you should remove the action
from the cache.action
- The action that just finished execution on the server.result
- The result after the server call, or null
if the server call failed.protected Cache getCache()
Copyright © 2010-2014 ArcBees. All Rights Reserved.