posts - 48, comments - 13, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

从dwr2.0到dwr3.0的转换(转载)

Posted on 2009-03-14 22:19 董锐 阅读(2902) 评论(0)  编辑  收藏

转自:http://www.nabble.com/sctx.getScriptSessionsByPage%28%29-problems-td19552209.html#a19552209

Hi,

Thanks for your response. So for the following code what is the updated
version?

CODE:

Update/modify the calling client only:

   WebContext wctx = WebContextFactory.get();
   if(wctx != null)
   {
     Util utilThis = new Util(wctx.getScriptSession());
     utilThis.setValue("web Page Element Name", "Web Page Element Value");
   }


import org.directwebremoting.ui.dwr.Util; /* i.e. NOT proxy.dwr.Util */
Util.setValue("web Page Element Name", "Web Page Element Value");

 

 

update all connected browsers viewing the relevant page:

 WebContext wctx = WebContextFactory.get();
 if (wctx != null)
 {
   String currentPage = wctx.getCurrentPage();
   Collection sessions = wctx.getScriptSessionsByPage(currentPage);
   Util utilAll = new Util(sessions);
   utilAll.addFunctionCall("createTable",tData);
 }

 


final Object tData = ...;
Browser.withCurrentPage(new Runnable() {
    public void run() {
        ScriptSessions.addFunctionCall("createTable", tData);
    }
});

 

 

update all browsers for a specific page (non DWR started thread)

 servletContext = WebContextFactory.get().getServletContext();
 sctx = ServerContextFactory.get(servletContext);
 if (sctx != null)
 {
    Collection sessions = sctx.getScriptSessionsByPage("/stocksdemo/");
    Util utilAll = new Util(sessions);
    utilAll.addFunctionCall("function To Call","Data to pass");
 }

 


Browser.withPage("/stocksdemo/",  new Runnable() {
    public void run() {

只有注册用户登录后才能发表评论。


网站导航: