/** * Call the dwr.engine.remote.handleResponse() in the browser * @param batchId The identifier of the batch that we are handling a response for * @param callId The identifier of the call that we are handling a response for * @param data The data to pass to the callback function * @return The script to send to the browser */ public static ScriptBuffer getRemoteHandleCallbackScript(String batchId, String callId, Object data) { ScriptBuffer script = new ScriptBuffer(); script.appendCall("dwr.engine.remote.handleCallback", batchId, callId, data); return script; }
/** * Call dwr.engine.remote.executeFunction() in the browser * @param id The registered function name * @param propertyName The name of the property to alter on the client object * @param data The new value for the client object property * @return The script to send to the browser */ public static ScriptBuffer getRemoteSetObjectScript(String id, String propertyName, Object data) { ScriptBuffer script = new ScriptBuffer(); script.appendCall("dwr.engine.remote.handleSetCall", id, propertyName, data); return script; }
/** * Call dwr.engine.remote.executeFunction() in the browser * @param id The registered function name * @param params The data to pass to the function * @return The script to send to the browser */ public static ScriptBuffer getRemoteExecuteFunctionScript(String id, Object[] params) { ScriptBuffer script = new ScriptBuffer(); script.appendCall("dwr.engine.remote.handleFunctionCall", id, params); return script; }
/** * Call dwr.engine.remote.executeFunction() in the browser * @param id The registered function name * @param params The data to pass to the function * @return The script to send to the browser */ public static ScriptBuffer getRemoteExecuteObjectScript(String id, String methodName, Object[] params) { ScriptBuffer script = new ScriptBuffer(); script.appendCall("dwr.engine.remote.handleObjectCall", id, methodName, params); return script; }
/** * Call dwr.engine.remote.closeFunction() in the browser * @param id The registered function name * @return The script to send to the browser */ public static ScriptBuffer getRemoteCloseFunctionScript(String id) { ScriptBuffer script = new ScriptBuffer(); script.appendCall("dwr.engine.remote.handleFunctionClose", id); return script; }
/** * Call dwr.engine.remote.handleException() in the browser * @param batchId The identifier of the batch that we are handling a response for * @param callId The id of the call we are replying to * @param ex The exception to throw on the remote end * @return The script to send to the browser */ public static ScriptBuffer getRemoteHandleExceptionScript(String batchId, String callId, Throwable ex) { ScriptBuffer script = new ScriptBuffer(); script.appendCall("dwr.engine.remote.handleException", batchId, callId, ex); return script; }
public void onMessage(MessageEvent message) { ScriptBuffer script = new ScriptBuffer(); script.appendCall("dwr.hub._remotePublish", subscriptionId, message.getRawData()); session.addScript(script); }
/** * Show a 'confirm' dialog * @param message The text to go into the alert box * @param callback The function to be called when a browser replies */ public static void confirm(String message, Callback<Boolean> callback) { ScriptBuffer script = new ScriptBuffer(); String callbackPrefix = ""; if (callback != null) { callbackPrefix = "var reply = "; } script.appendCall(callbackPrefix + "confirm", message); if (callback != null) { String key = CallbackHelperFactory.get().saveCallback(callback, Boolean.class); script.appendCall("__System.activateCallback", key, "reply"); } ScriptSessions.addScript(script); }
/** * Show a 'prompt' dialog * @param message The text to go into the alert box * @param callback The function to be called when a browser replies */ public static void prompt(String message, Callback<String> callback) { ScriptBuffer script = new ScriptBuffer(); String callbackPrefix = ""; if (callback != null) { callbackPrefix = "var reply = "; } script.appendCall(callbackPrefix + "prompt", message); if (callback != null) { String key = CallbackHelperFactory.get().saveCallback(callback, String.class); script.appendCall("__System.activateCallback", key, "reply"); } ScriptSessions.addScript(script); }