转自: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() {