Search in sources :

Example 6 with ScriptBuffer

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

the class Engine method setAsync.

/**
 * Do we ask the XHR object to be asynchronous? (Default: true)
 * @param async False to become synchronous (not recommended)
 * @see <a href="http://getahead.org/dwr/browser/engine/options">Options documentation</a>
 */
public void setAsync(boolean async) {
    ScriptBuffer script = new ScriptBuffer();
    script.appendScript("dwr.engine.setAsync(").appendData(async).appendScript(");");
    addScript(script);
}
Also used : ScriptBuffer(org.directwebremoting.ScriptBuffer)

Example 7 with ScriptBuffer

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

the class Engine method setPollType.

/**
 * Set the preferred polling type.
 * @param newPollType One of {@link #XMLHttpRequest}, {@link #IFrame} or {@link #ScriptTag}
 * @see <a href="http://getahead.org/dwr/browser/engine/options">Options documentation</a>
 */
public void setPollType(int newPollType) {
    ScriptBuffer script = new ScriptBuffer();
    script.appendScript("dwr.engine.setPollUsingComet(").appendData(newPollType).appendScript(");");
    addScript(script);
}
Also used : ScriptBuffer(org.directwebremoting.ScriptBuffer)

Example 8 with ScriptBuffer

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

the class Util method removeNode.

/**
 * 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);
}
Also used : ScriptBuffer(org.directwebremoting.ScriptBuffer)

Example 9 with ScriptBuffer

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

the class Util method setStyle.

/**
 * Sets a CSS style on an element
 * @param elementId The HTML element to update (by id)
 * @param selector The CSS selector to update
 * @param value The new value for the CSS class on the given element
 */
public void setStyle(String elementId, String selector, String value) {
    ScriptBuffer script = new ScriptBuffer();
    script.appendScript("dwr.util.byId(").appendData(elementId).appendScript(").style.").appendScript(selector).appendScript("=").appendData(value).appendScript(";");
    addScript(script);
}
Also used : ScriptBuffer(org.directwebremoting.ScriptBuffer)

Example 10 with ScriptBuffer

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

the class DwrConvertTag method doStartTag.

@Override
public int doStartTag() throws JspException {
    ServletContext servletContext = pageContext.getServletContext();
    Container container = (Container) servletContext.getAttribute("DwrContainer");
    if (container == null)
        throw new JspException("Can't find 'DwrContainer' in servlet context");
    ConverterManager converterManager = (ConverterManager) container.getBean(ConverterManager.class.getName());
    final ScriptBuffer scriptBuffer = new ScriptBuffer();
    scriptBuffer.appendScript("return ");
    scriptBuffer.appendData(obj);
    WebContextBuilder webContextBuilder = (WebContextBuilder) servletContext.getAttribute(WebContextBuilder.class.getName());
    try {
        webContextBuilder.set((HttpServletRequest) pageContext.getRequest(), (HttpServletResponse) pageContext.getResponse(), null, servletContext, container);
        JspWriter out = pageContext.getOut();
        out.write("function() {");
        out.write(ScriptBufferUtil.createOutput(scriptBuffer, converterManager));
        out.write(";}()");
    } catch (IOException e) {
        throw new JspException("Error writing tag content", e);
    } catch (MarshallException e) {
        throw new JspException("Error marshalling object data", e);
    } finally {
        webContextBuilder.unset();
    }
    return EVAL_PAGE;
}
Also used : JspException(javax.servlet.jsp.JspException) Container(org.directwebremoting.Container) ConverterManager(org.directwebremoting.extend.ConverterManager) MarshallException(org.directwebremoting.extend.MarshallException) ServletContext(javax.servlet.ServletContext) WebContextBuilder(org.directwebremoting.WebContextFactory.WebContextBuilder) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter) 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