1 16 package org.getahead.dwrdemo.livehelp; 17 18 import java.util.Collection ; 19 20 import org.directwebremoting.Security; 21 import org.directwebremoting.WebContext; 22 import org.directwebremoting.WebContextFactory; 23 import org.directwebremoting.proxy.dwr.Util; 24 import org.directwebremoting.util.Logger; 25 26 30 public class LiveHelp 31 { 32 37 public void notifyTyping(String id, String value) 38 { 39 Util utilAll = new Util(getUsersToAffect()); 40 41 utilAll.setValue(id, Security.replaceXmlCharacters(value)); 42 } 43 44 48 public void notifyFocus(String id) 49 { 50 Util utilAll = new Util(getUsersToAffect()); 51 52 utilAll.addClassName(id, "disabled"); 53 String addr = WebContextFactory.get().getHttpServletRequest().getRemoteAddr(); 54 utilAll.setValue(id + "Tip", addr); 55 56 } 58 59 63 public void notifyBlur(String id) 64 { 65 Util utilAll = new Util(getUsersToAffect()); 66 67 utilAll.removeClassName(id, "disabled"); 68 utilAll.setValue(id + "Tip", ""); 69 70 } 72 73 76 private Collection getUsersToAffect() 77 { 78 WebContext wctx = WebContextFactory.get(); 79 String currentPage = wctx.getCurrentPage(); 80 81 Collection sessions = wctx.getScriptSessionsByPage(currentPage); 83 84 sessions.remove(wctx.getScriptSession()); 86 87 log.debug("Affecting " + sessions.size() + " users"); 88 89 return sessions; 90 } 91 92 95 private static final Logger log = Logger.getLogger(LiveHelp.class); 96 } 97
| Popular Tags
|