java-dwr-3.0推使用
- 格式:doc
- 大小:42.50 KB
- 文档页数:6
1.
2. listener.MyHttpSessionListener
3.
DWR ScriptSession监听(web.xml)
1.
2.
3. org.directwebremoting.event.ScriptSessionListener
4.
5.
6. listener.ScriptSessionListenerImpl,
7.
8.
DWR ScriptSessionManager(web.xml)
1.
2.
3. org.directwebremoting.extend.ScriptSessionManager
4.
5. listener.MyScriptSessionManager
6.
activeReverseAjaxEnabled
true
initApplicationScopeCreatorsAtStartup
true
jsonRpcEnabled
true
jsonpEnabled
true
preferDataUrlSchema
false
org.directwebremoting.extend.ServerLoadMonitor
org.directwebremoting.impl.PollingServerLoadMonitor
disconnectedTime
30000
org.directwebremoting.event.ScriptSessionListener
com.shguo.chat.dwr.MyScriptSessionListener,
org.directwebremoting.proxy.dwr.Util work
Util.setValue()
Util(sessions);
ScriptBuffer script = new ScriptBuffer();
script.appendScript("alert(1)");
ServerContext sctx = ServerContextFactory.get(servletContext ); //FIXME
WCTX
if(sctx!=null)
{
Collection pages =
sctx.getScriptSessionsByPage("/HustMes/pages/menu/pbsZoneLayoutAction.action");
);
for (ScriptSession session : pages)
{
session.addScript(script);
}
}
并且如果是非页面调用的话 要给类注入 servletContext
dwr3.0
Browser.withSession(wctx.getScriptSession().getId(), new Runnable() {
public void run() {
ScriptSessions.addFunctionCall("receiveMessages", messages);
}
});
or
Browser.withAllSessionsFiltered(new Filter(),new Runnable() {
public void run() {
ScriptSessions.addFunctionCall("receiveMessages", messages);
}
});
String page = ServerContextFactory.get().getContextPath() + "xxx.jsp";
Browser.withPage(page,new Runnable() {
public void run() {
ScriptSessions.addScript("alert(1)");
}
});
((ScriptSession)session).addScript(script);
增加自己的监听器:
1.
2. listener.MyHttpSessionListener
3.
DWR ScriptSession监听(web.xml)
1.
2.
3. org.directwebremoting.event.ScriptSessionListener
4.
5.
6. listener.ScriptSessionListenerImpl,
7.
8.