Package org.directwebremoting

Examples of org.directwebremoting.ScriptBuffer


            ServerContext context = ServerContextFactory.get();
            //��ÿͻ�������chatҳ��script session������
            Collection<ScriptSession> sessions = context.getScriptSessionsByPage(((ServerContext) ctx).getContextPath() + "/chat.jsp");
            for (ScriptSession session : sessions) {
                ScriptBuffer sb = new ScriptBuffer();
                Date time = msg.getTime();
                @SuppressWarnings("deprecation")
        String s = time.getYear() + "-" + (time.getMonth() + 1) + "-" +  time.getDate() + " "
                        +  time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
                //ִ��setMessage����
                sb.appendScript("showMessage({msg: '")
                .appendScript(msg.getMsg())
                .appendScript("', time: '")
                .appendScript(s)
                .appendScript("'})");
                System.out.println(sb.toString());
                //ִ�пͻ���script session�������൱�������ִ��JavaScript����
                  //����ͻ�ִ�пͻ���������е�showMessage���������Ҵ���һ�������ȥ
                session.addScript(sb);
            }
View Full Code Here


        ScriptSession scriptSessions = null
        Collection<ScriptSession> sessions = new HashSet<ScriptSession>();
        sessions.addAll(ServerContextFactory.get(request.getSession().getServletContext()) 
                .getScriptSessionsByPage("/fly-web/ind.jsp"))
        for (ScriptSession session1 : sessions) {         
            ScriptBuffer sb = new ScriptBuffer();
            sb.appendScript("showMessage({msg: '").appendScript(msg).appendScript("'})");
            System.out.println(sb.toString());
           
            session.addScript(sb);
       
        Util util = new Util(session)
        util.setStyle("showMessage", "display", "")
View Full Code Here

        // Get a DWR Util proxy for all the browsers on the current page:
        Collection sessions = wctx.getScriptSessionsByPage(currentPage);
        Util utilAll = new Util(sessions);

        ScriptBuffer referenceInvoke = getInvokeFragment(args, wctx);

        // add the reference call to the Util proxy which will cause DWR to
        // asynchronously send it to be run on each active browser client
        utilAll.addScript(referenceInvoke);
    }
View Full Code Here

     * Creates a fragment of JavaScript code to invoke the reference function
     * Eg: "<referenceName>.<operationName>(arg1, arg2,...);"
     */
    protected ScriptBuffer getInvokeFragment(Object[] args, WebContext wctx) {

        ScriptBuffer sb = new ScriptBuffer();
        sb.appendScript(referenceFunction);
        sb.appendScript("(");
        if (args != null) {
            for (int i = 0; i < args.length; i++) {
                sb.appendData(args[i]);
                if (i < (args.length - 1)) {
                    sb.appendScript(", ");
                }
            }
        }
        sb.appendScript(");");

        return sb;
    }
View Full Code Here

        // Get a DWR Util proxy for all the browsers on the current page:
        Collection sessions = wctx.getScriptSessionsByPage(currentPage);
        Util utilAll = new Util(sessions);

        ScriptBuffer referenceInvoke = getInvokeFragment(args, wctx);

        // add the reference call to the Util proxy which will cause DWR to
        // asynchronously send it to be run on each active browser client
        utilAll.addScript(referenceInvoke);
    }
View Full Code Here

     * Creates a fragment of JavaScript code to invoke the reference function
     * Eg: "<referenceName>.<operationName>(arg1, arg2,...);"
     */
    protected ScriptBuffer getInvokeFragment(Object[] args, WebContext wctx) {

        ScriptBuffer sb = new ScriptBuffer();
        sb.appendScript(referenceFunction);
        sb.appendScript("(");
        if (args != null) {
            for (int i = 0; i < args.length; i++) {
                sb.appendData(args[i]);
                if (i < (args.length - 1)) {
                    sb.appendScript(", ");
                }
            }
        }
        sb.appendScript(");");

        return sb;
    }
View Full Code Here

        // Get a DWR Util proxy for all the browsers on the current page:
        Collection sessions = wctx.getScriptSessionsByPage(currentPage);
        Util utilAll = new Util(sessions);

        ScriptBuffer referenceInvoke = getInvokeFragment(args, wctx);

        // add the reference call to the Util proxy which will cause DWR to
        // asynchronously send it to be run on each active browser client
        utilAll.addScript(referenceInvoke);
    }
View Full Code Here

     * Creates a fragment of JavaScript code to invoke the reference function
     * Eg: "<referenceName>.<operationName>(arg1, arg2,...);"
     */
    protected ScriptBuffer getInvokeFragment(Object[] args, WebContext wctx) {

        ScriptBuffer sb = new ScriptBuffer();
        sb.appendScript(referenceFunction);
        sb.appendScript("(");
        if (args != null) {
            for (int i = 0; i < args.length; i++) {
                sb.appendData(args[i]);
                if (i < (args.length - 1)) {
                    sb.appendScript(", ");
                }
            }
        }
        sb.appendScript(");");

        return sb;
    }
View Full Code Here

  // update other users.
  @Deprecated
  public String openURL(String url) {
    _logger.debug("openurl called with        "+ url ); //$NON-NLS-1$
    WebContext wctx = WebContextFactory.get();
        ScriptBuffer script = new ScriptBuffer();
        script.appendScript("window.open(") //$NON-NLS-1$
        .appendData(url)
        .appendScript(");");        //$NON-NLS-1$
        wctx.getScriptSession().addScript(script);
        return ""; //$NON-NLS-1$
  }
View Full Code Here

     */
    public void writeData(PrintWriter out, Object data, String callback)
    {
        try
        {
            ScriptBuffer buffer = new ScriptBuffer();
            buffer.appendData(data);

            String output = ScriptBufferUtil.createOutput(buffer, converterManager, true);
            if (data instanceof Exception)
            {
                output = "{\"error\":" + output + "}";
            }
            if (callback != null && !"".equals(callback.trim()))
            {
                output = callback + "(" + output + ")";
            }
            out.println(output);
        }
        catch (ConversionException ex)
        {
            log.warn("--ConversionException: class=" + ex.getConversionType().getName(), ex);

            ScriptBuffer buffer = new ScriptBuffer();
            buffer.appendData(ex);

            try
            {
                String output = ScriptBufferUtil.createOutput(buffer, converterManager, true);
                output = "{\"error\":" + output + "}";
View Full Code Here

TOP

Related Classes of org.directwebremoting.ScriptBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.