Search in sources :

Example 16 with ScriptBuffer

use of org.directwebremoting.ScriptBuffer in project ma-core-public by infiniteautomation.

the class Util method addRows.

/**
 * Create rows inside a the table, tbody, thead or tfoot element (given by id).
 * <p><a href="http://getahead.org/dwr/browser/tables">More</a>.
 * @param elementId The HTML element to update (by id)
 * @param data The cells to add to the table
 * @param options See link above for documentation on the options
 */
public void addRows(String elementId, String[][] data, String options) {
    if (data.length > 0) {
        StringBuffer functions = new StringBuffer();
        for (int i = 0; i < data[0].length; i++) {
            functions.append("function(data) { return data[" + i + "]},");
        }
        functions.deleteCharAt(functions.length() - 1);
        ScriptBuffer script = new ScriptBuffer();
        script.appendScript("dwr.util.addRows(").appendData(elementId).appendScript(",").appendData(data).appendScript(",").appendScript("[" + functions.toString() + "]").appendScript(options == null ? "" : ", " + options).appendScript(");");
        addScript(script);
    }
}
Also used : ScriptBuffer(org.directwebremoting.ScriptBuffer)

Example 17 with ScriptBuffer

use of org.directwebremoting.ScriptBuffer in project ma-core-public by infiniteautomation.

the class Util method cloneNode.

/**
 * Clone a given node.
 * <p><a href="http://getahead.org/dwr/browser/TODO">More</a>.
 * @param elementId The HTML element to update (by id)
 * @param idPrefix How do we prefix ids in the cloned version of the node tree
 * @param idSuffix How do we suffix ids in the cloned version of the node tree
 */
public void cloneNode(String elementId, String idPrefix, String idSuffix) {
    ScriptBuffer script = new ScriptBuffer();
    script.appendScript("dwr.util.cloneNode(").appendData(elementId).appendScript(", { idPrefix:").appendData(idPrefix).appendScript(", idSuffix:").appendData(idSuffix).appendScript("});");
    addScript(script);
}
Also used : ScriptBuffer(org.directwebremoting.ScriptBuffer)

Example 18 with ScriptBuffer

use of org.directwebremoting.ScriptBuffer in project ma-core-public by infiniteautomation.

the class Effect method callEffect.

/**
 * @param elementId The element to affect
 * @param function The script.aculo.us effect to employ
 * @param options A string containing options to pass to the script.aculo.us effect, as specified at http://script.aculo.us/
 */
private void callEffect(String elementId, String function, String options) {
    ScriptBuffer script = new ScriptBuffer();
    script.appendScript("new Effect.").appendScript(function).appendScript("('").appendScript(elementId).appendScript("'");
    if (options != null && options.length() > 0) {
        script.appendScript(", ").appendScript(options);
    }
    script.appendScript(");");
    addScript(script);
}
Also used : ScriptBuffer(org.directwebremoting.ScriptBuffer)

Example 19 with ScriptBuffer

use of org.directwebremoting.ScriptBuffer in project ma-core-public by infiniteautomation.

the class EnginePrivate method remoteHandleCallback.

/**
 * Call the dwr.engine._remoteHandleResponse() in the browser
 * @param conduit The browser pipe to write to
 * @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
 * @throws IOException If writing fails.
 * @throws MarshallException If objects in the script can not be marshalled
 */
public static void remoteHandleCallback(ScriptConduit conduit, String batchId, String callId, Object data) throws IOException, MarshallException {
    ScriptBuffer script = new ScriptBuffer();
    script.appendScript("dwr.engine._remoteHandleCallback(\'").appendScript(batchId).appendScript("\',\'").appendScript(callId).appendScript("\',").appendData(data).appendScript(");");
    conduit.addScript(script);
}
Also used : ScriptBuffer(org.directwebremoting.ScriptBuffer)

Example 20 with ScriptBuffer

use of org.directwebremoting.ScriptBuffer in project ma-core-public by infiniteautomation.

the class EnginePrivate method remoteHandleMarshallException.

/**
 * Call the dwr.engine._remoteHandleException() in the browser
 * @param conduit The browser pipe to write to
 * @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
 * @throws IOException If writing fails.
 */
public static void remoteHandleMarshallException(ScriptConduit conduit, String batchId, String callId, MarshallException ex) throws IOException {
    try {
        ScriptBuffer script = new ScriptBuffer();
        script.appendScript("dwr.engine._remoteHandleException(\'").appendScript(batchId).appendScript("\',\'").appendScript(callId).appendScript("\',").appendData(ex).appendScript(");");
        conduit.addScript(script);
    } catch (MarshallException mex) {
        ScriptBuffer script = new ScriptBuffer();
        script.appendScript("dwr.engine._remoteHandleException(\'").appendScript(batchId).appendScript("\',\'").appendScript(callId).appendScript("\',").appendData(mex).appendScript(");");
        addScriptWithoutException(conduit, script);
    }
}
Also used : ScriptBuffer(org.directwebremoting.ScriptBuffer)

Aggregations

ScriptBuffer (org.directwebremoting.ScriptBuffer)20 IOException (java.io.IOException)1 ServletContext (javax.servlet.ServletContext)1 JspException (javax.servlet.jsp.JspException)1 JspWriter (javax.servlet.jsp.JspWriter)1 Container (org.directwebremoting.Container)1 ScriptSession (org.directwebremoting.ScriptSession)1 WebContextBuilder (org.directwebremoting.WebContextFactory.WebContextBuilder)1 ConverterManager (org.directwebremoting.extend.ConverterManager)1 MarshallException (org.directwebremoting.extend.MarshallException)1