本帖最后由 jackie319 于 2010-12-10 09:20:13 编辑

解决方案 »

  1.   

    <body onload="dwr.engine.setActiveReverseAjax(true);sendMessage();">
    function sendMessage() {
    var storeId = document.getElementById("storeId").value;
    orderNotice.noticeNewOrder(storeId);
    }这个copy漏了。// 获得DWR上下文
    WebContext wctx = WebContextFactory.get();
    // 获取当前页面URL
    String currentPage = wctx.getCurrentPage();

    /* ServletContext application = this.getServletContext();
     application.getAttribute("orderId");
     System.out.println("application"+application.getAttribute("orderId"));
    */
    // 获取所有浏览当前页面的脚本session
    Collection<ScriptSession> sessions = wctx
    .getScriptSessionsByPage(currentPage);
    System.out.println("多少个客户端?" + sessions.size());
    // 执行客户端脚本
    ScriptBuffer script = new ScriptBuffer();
    script.appendScript("receiveMessages("+num+");");
    for (ScriptSession session : sessions) {

    session.addScript(script);

    }
    可是每刷新一下就有一个新的ScriptSeesion?不知道要怎么管理session。我现在写的例子推2次就停了。郁闷!!!!
      

  2.   


    copy漏了。。为什么我的推了2次就停了呢?