Remoting Hooks

If you wish to be alerted before DWR actually remotes a call you can set a pre-hook function. This will be called with no parameters. This hook is useful if you wish to grey out certain components to prevent them being used again until the call returns.

Post execute hooks will usually be set in conjunction with pre-execute hooks and will generally undo any changes made by the pre-hook.

To set a preHook or postHook function globally see dwr.engine.setPreHook(function) and dwr.engine.setPostHook(function).

You can also set a preHook or postHook function on a per-call basis using the call options object:

Remote.method(params, {
  callback:function(data) { alert("it worked"); },
  preHook:function() { alert("Calling remote method."); },
  postHook:function() { alert("Remote call complete."); }
});

For an example of pre and post hooks, see the dwr.util.useLoadingMessage() function.