/** * Utility to add the given script to all known browsers. * This version automatically wraps the string in a ClientScript object. * @param scriptString The Javascript to send to the browsers */ public static void addScript(String scriptString) { addScript(new ScriptBuffer(scriptString)); }
/** * 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; }
/** * Navigate to a new page * @param newPage The page to navigate to */ public static void setLocation(String newPage) { ScriptBuffer script = new ScriptBuffer(); script.appendData("window.location = '" + newPage + "';"); ScriptSessions.addScript(script); }
public void onMessage(MessageEvent message) { ScriptBuffer script = new ScriptBuffer(); script.appendCall("dwr.hub._remotePublish", subscriptionId, message.getRawData()); session.addScript(script); }
/** * Call a named function with no parameters. * @param funcName The name of the function to call */ public void addFunctionCall(String funcName) { ScriptBuffer script = new ScriptBuffer(); script.appendScript(funcName) .appendScript("();"); addScript(script); }
/** * Does DWR us comet polling? (Default: true) * @param pollComet True/False to use Comet where supported */ public static void setPollUsingComet(boolean pollComet) { ScriptBuffer script = new ScriptBuffer(); script.appendScript("dwr.engine.setPollUsingComet(") .appendData(pollComet) .appendScript(");"); ScriptSessions.addScript(script); }
/** * Set the preferred remoting type. * @param newType One of dwr.engine.XMLHttpRequest or dwr.engine.IFrame or dwr.engine.ScriptTag */ public void setRpcType(int newType) { ScriptBuffer script = new ScriptBuffer(); script.appendScript("dwr.engine.setRpcType(") .appendData(newType) .appendScript(");"); addScript(script); }
/** * Does DWR us comet polling? (Default: true) * @param pollComet True/False to use Comet where supported */ public void setPollUsingComet(boolean pollComet) { ScriptBuffer script = new ScriptBuffer(); script.appendScript("dwr.engine.setPollUsingComet(") .appendData(pollComet) .appendScript(");"); addScript(script); }
/** * Set a default timeout value for all calls. 0 (the default) turns timeouts off. * @param timeout The time to wait in milliseconds */ public static void setTimeout(int timeout) { ScriptBuffer script = new ScriptBuffer(); script.appendScript("dwr.engine.setTimeout(") .appendData(timeout) .appendScript(");"); ScriptSessions.addScript(script); }
/** * Set the preferred remoting type. * @param newType One of dwr.engine.XMLHttpRequest or dwr.engine.IFrame or dwr.engine.ScriptTag */ public static void setRpcType(int newType) { ScriptBuffer script = new ScriptBuffer(); script.appendScript("dwr.engine.setRpcType(") .appendData(newType) .appendScript(");"); ScriptSessions.addScript(script); }
/** * Which HTTP method do we use to send results? Must be one of "GET" or "POST". * @param httpMethod One of {@link #XMLHttpRequest}, {@link #IFrame} or {@link #ScriptTag} */ public static void setHttpMethod(String httpMethod) { ScriptBuffer script = new ScriptBuffer(); script.appendScript("dwr.engine.setHttpMethod(") .appendData(httpMethod) .appendScript(");"); ScriptSessions.addScript(script); }
/** * Ensure that remote calls happen in the order in which they were sent? (Default: false) * @param ordered True to set call ordering. */ public static void setOrdered(boolean ordered) { ScriptBuffer script = new ScriptBuffer(); script.appendScript("dwr.engine.setOrdered(") .appendData(ordered) .appendScript(");"); ScriptSessions.addScript(script); }
/** * Does DWR poll the server for updates? (Default: false) * @param activeReverseAjax True/False to turn RA on/off */ public void setActiveReverseAjax(boolean activeReverseAjax) { ScriptBuffer script = new ScriptBuffer(); script.appendScript("dwr.engine.setActiveReverseAjax(") .appendData(activeReverseAjax) .appendScript(");"); addScript(script); }
/** * Do we ask the XHR object to be asynchronous? (Default: true) * @param async False to become synchronous (not recommended) */ public static void setAsync(boolean async) { ScriptBuffer script = new ScriptBuffer(); script.appendScript("dwr.engine.setAsync(") .appendData(async) .appendScript(");"); ScriptSessions.addScript(script); }
/** * Set a default timeout value for all calls. 0 (the default) turns timeouts off. * @param timeout The time to wait in milliseconds */ public void setTimeout(int timeout) { ScriptBuffer script = new ScriptBuffer(); script.appendScript("dwr.engine.setTimeout(") .appendData(timeout) .appendScript(");"); addScript(script); }
/** * Which HTTP method do we use to send results? Must be one of "GET" or "POST". * @param httpMethod One of {@link #XMLHttpRequest}, {@link #IFrame} or {@link #ScriptTag} */ public void setHttpMethod(String httpMethod) { ScriptBuffer script = new ScriptBuffer(); script.appendScript("dwr.engine.setHttpMethod(") .appendData(httpMethod) .appendScript(");"); addScript(script); }
/** * Ensure that remote calls happen in the order in which they were sent? (Default: false) * @param ordered True to set call ordering. */ public void setOrdered(boolean ordered) { ScriptBuffer script = new ScriptBuffer(); script.appendScript("dwr.engine.setOrdered(") .appendData(ordered) .appendScript(");"); addScript(script); }
/** * Set the preferred polling type. * @param newPollType One of {@link #XMLHttpRequest}, {@link #IFrame} or {@link #ScriptTag} */ public void setPollType(int newPollType) { ScriptBuffer script = new ScriptBuffer(); script.appendScript("dwr.engine.setPollUsingComet(") .appendData(newPollType) .appendScript(");"); addScript(script); } }
/** * Sets a CSS style on an element * @param elementId The HTML element to update (by id) */ public void removeNode(String elementId) { ScriptBuffer script = new ScriptBuffer(); script.appendScript("dwr.util._temp = dwr.util.byId(") .appendData(elementId) .appendScript("); ") .appendScript("if (dwr.util._temp) { dwr.util._temp.parentNode.removeChild(dwr.util._temp); dwr.util._temp = null; }"); addScript(script); }