开发学院网页设计JavaScript 模式 + GWT + Ajax = 易用性 阅读

模式 + GWT + Ajax = 易用性

 2009-09-12 00:00:00 来源:WEB开发网   
核心提示: 清单 4. 预抓取模式伪代码class_with_cache_and_pre-fetchingcode:defineclassattributesforthecache(ahashmap,array,whatever)setthecachetoemptyload_datamethod:check

清单 4. 预抓取模式伪代码

   
class_with_cache_and_pre-fetching code: 
  define class attributes for the cache (a hash map, array, whatever) 
  set the cache to empty 
 
  load_data method: 
    check if the asked data are already in the cache 
    if so, 
      get the data from the cache 
      perform whatever needs be done with it 
    otherwise, 
      display an appropriate "loading" message 
      call a server-side service to get the data 
      on callback: 
        put the data in the cache 
        if data were needed (as opposed to prefetched), 
          perform whatever needs be done with it 
 
  processing_data method: 
    call the load_data method to get that data 
    call the load_data method to get extra (prefetched) data 
      

模式:线程模拟

现在考虑处理器密集型任务,比如处理大量 XML 或显示大量数据。如果任务花费的时间太长,用户就会收到消息:在 Firefox 浏览器上,“A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete”;在 Windows® Internet Explorer® 上,“Stop running this script? A script on this page is causing Internet Explorer to run slowly. If it continues to run, your computer may become unresponsive”。更糟糕的是,如果用户注意到这个警告并停止脚本,那么实际上就取消了您的客户端程序!

上一页  3 4 5 6 7 8 9 10  下一页

Tags:模式 GWT Ajax

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接