7. 我們的目標 Web 聊天室 http:// gabbly.com/http://www.pocketshark.com/blog/page/tempo / http://localhost:8080/dwr-chat/before.jsp http://localhost:8080/dwr-chat/after.jsp
8. What We Will Focus on Here Browser Compatibility, Cross-Domains, Java Data Marshalling, JSON , JSON-RPC, DOJO, DWR, GWT, iframe , Prototype, Timeout & Error Handling, Reverse AJAX, History & Bookmarks, scriptTag , Web Framework Integration, XHR, XML
23. 瀏覽器支援 XHR 支援以下瀏覽器 IE 5.0+ Mozilla 1.0+ Safari 1.2 Konqueor Opera 8.0 但不同的瀏覽器 XHR 建立方式不同 IE: ActiveX Others: JavaScript
24. 瀏覽器支援 function httpRequest (reqType,url){ if(window. XMLHttpRequest ){ // Mozilla, Opera, Safari, … request = new XMLHttpRequest(); } else if (window. ActiveXObject ){ // IE request=new ActiveXObject("Msxml2.XMLHTTP"); if (!request){ request=new ActiveXObject("Microsoft.XMLHTTP"); } } if(request){ … } else { alert(" Your browser does not permit the use of all "+ "of this application's features! "); } }
40. DWR(Direct Web Remoting) RPC-Style AJAX Easy AJAX for Java Easy to integrate AJAX : Expose Java to the Browser Reverse AJAX : Expose JavaScript to the Server
77. Step1: 建立伺服器端的 Java 物件 public void addMessage (String text) { … final WebContext wctx = WebContextFactory. get (); // For all the browsers on the current page: String currentPage = wctx. getCurrentPage (); Collection sessions = wctx. getScriptSessionsByPage (currentPage); DwrUtil utilAll = new DwrUtil(sessions); utilAll.removeAllOptions("chatlog"); utilAll.addOptions("chatlog", messages, "text"); }