不做浮躁的人
          正在行走的人...
          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)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 平利县| 绵阳市| 登封市| 天台县| 镇巴县| 孙吴县| 临漳县| 锡林浩特市| 且末县| 会理县| 安化县| 兴义市| 五台县| 邵阳市| 芦溪县| 建瓯市| 张北县| 曲阜市| 扎鲁特旗| 十堰市| 汉寿县| 高阳县| 永泰县| 安图县| 手游| 霸州市| 扎兰屯市| 那曲县| 邻水| 邓州市| 泰来县| 阿拉善右旗| 红桥区| 安远县| 长子县| 射洪县| 新源县| 绵竹市| 平谷区| 秦皇岛市| 长汀县|