不做浮躁的人
          正在行走的人...
          posts - 171,  comments - 51,  trackbacks - 0

          我們接dojoTree Controller(1)繼續討論 TreeLoadingController
          1:該類在TreeBasicController基礎上增加了RPCUrl和RPCActionParam(默認為action)兩個參數。解釋這兩個參數必須看下面的代碼:
          if (this.RPCUrl == "local") {
          ???var dir = document.location.href.substr(0, document.location.href.lastIndexOf('/'));
          ???var localUrl = dir+"/"+action;
          ???//dojo.debug(localUrl);
          ???return localUrl;
          ??}

          ??if (!this.RPCUrl) {
          ???dojo.raise("Empty RPCUrl: can't load");
          ??}

          ??return this.RPCUrl + ( this.RPCUrl.indexOf("?") > -1 ? "&" : "?") + this.RPCActionParam+"="+action;

          2:通用的錯誤處理器:
          ??RPCErrorHandler: function(type, obj, evt) {
          ??alert( "RPC Error: " + (obj.message||"no message"));
          ?},
          可以自己定義處理方式。

          3:看以下runRPC的這段代碼,就能明白服務器端該怎么處理請求:
          dojo.io.bind({
          ???url: kw.url,
          ???/* I hitch to get this.loadOkHandler */
          ???handle: dojo.lang.hitch(this, handle),
          ???mimetype: "text/json",
          ???preventCache: true,
          ???sync: kw.sync,
          ???content: { data: dojo.json.serialize(kw.params) }?
          ??});
          4:loadRemote是動態裝載該節點的子節點的方法,可以看看該方法的rpc部分:
          var params = {
          ???node: this.getInfo(node),
          ???tree: this.getInfo(node.tree)
          ??};
          dojo.io.bind({
          ???url: kw.url,
          ???/* I hitch to get this.loadOkHandler */
          ???handle: dojo.lang.hitch(this, handle),
          ???mimetype: "text/json",
          ???preventCache: true,
          ???sync: kw.sync,
          ???content: { data: dojo.json.serialize(kw.params) }
          ??});
          5:相對TreeBasicController,該Controller還重寫了doMove和doCreateChild方法。
          doMove: function(child, newParent, index) {
          ??/* load nodes into newParent in sync mode, if needed, first */
          ??if (newParent.isTreeNode && newParent.state == newParent.loadStates.UNCHECKED) {
          ???this.loadRemote(newParent, true);
          ??}

          ??return dojo.widget.TreeBasicController.prototype.doMove.apply(this, arguments);
          ?},
          可以看到是在同步處理完服務器的請求后,再執行的客戶端操作。因此我們只要在服務器端處理添加新節點和移動節點時,只要返回true或false就可以了。

          posted on 2006-11-22 23:15 不做浮躁的人 閱讀(996) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          <2006年11月>
          2930311234
          567891011
          12131415161718
          19202122232425
          262728293012
          3456789

          常用鏈接

          留言簿(9)

          隨筆分類(31)

          隨筆檔案(75)

          文章分類(1)

          文章檔案(3)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 康乐县| 江源县| 前郭尔| 长子县| 新巴尔虎左旗| 通州市| 札达县| 原阳县| 新龙县| 张北县| 克东县| 海林市| 敦化市| 美姑县| 象州县| 驻马店市| 阳江市| 贵溪市| 定南县| 饶阳县| 澳门| 金秀| 蒙阴县| 朔州市| 楚雄市| 黎川县| 苗栗市| 大埔区| 鹤庆县| 奉化市| 陕西省| 无锡市| 桂东县| 临夏市| 开原市| 阜宁县| 广水市| 剑川县| 陈巴尔虎旗| 广安市| 大邑县|