- 浏览: 1433736 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
luhouxiang:
写的很不错,学习了
Extjs 模块化动态加载js实践 -
kingkongtown:
如果想改成淘宝后台那样,可以在编辑器批量上传图片呢?
kissy editor 阶段体会 -
317966578:
兄弟我最近也在整jquery和caja 开放一些接口。在git ...
caja 原理 : 前端 -
liuweihug:
Javascript引擎单线程机制及setTimeout执行原 ...
setTimeout ,xhr,event 线程问题 -
辽主临轩:
怎么能让浏览器不进入 文档模式的quirks模式,进入标准的
浏览器模式与文本模式
//(代码系转载:) Ext.namespace("Ext.ux.data"); /** * @class Ext.ux.data.DWRProxy * @extends Ext.data.DataProxy * @author loeppky * An implementation of Ext.data.DataProxy that uses DWR to make a remote call. * @constructor * @param {Object} config A configuration object. */ Ext.ux.data.DWRProxy = function(config) { Ext.apply(this, config); // necessary since the superclass doesn't call apply Ext.ux.data.DWRProxy.superclass.constructor.call(this); }; Ext.extend(Ext.ux.data.DWRProxy, Ext.data.DataProxy, { /** * @cfg {Function} dwrFunction The DWR function for this proxy to call during load. * Must be set before calling load. */ dwrFunction: null, /** * @cfg {String} loadArgsKey Defines where in the params object passed to the load method * that this class should look for arguments to pass to the "dwrFunction". * The order of arguments passed to a DWR function matters. * Must be set before calling load. * See the explanation of the "params" parameter for the load function for further explanation. */ loadArgsKey: 'dwrFunctionArgs', /** * Load data from the configured "dwrFunction", * read the data object into a block of Ext.data.Records using the passed {@link Ext.data.DataReader} implementation, * and process that block using the passed callback. * @param {Object} params An object containing properties which are to be used for the request to the remote server. * Params is an Object, but the "DWR function" needs to be called with arguments in order. * To ensure that one's arguments are passed to their DWR function correctly, a user must either: * 1. call or know that the load method was called explictly where the "params" argument's properties were added in the order expected by DWR OR * 2. listen to the "beforeload" event and add a property to params defined by "loadArgsKey" that is an array of the arguments to pass on to DWR. * If there is no property as defined by "loadArgsKey" within "params", then the whole "params" object will be used as the "loadArgs". * If there is a property as defined by "loadArgsKey" within "params", then this property will be used as the "loagArgs". * The "loadArgs" are iterated over to build up the list of arguments to pass to the "dwrFunction". * @param {Ext.data.DataReader} reader The Reader object which converts the data object into a block of Ext.data.Records. * @param {Function} callback The function into which to pass the block of Ext.data.Records. * The function must be passed <ul> * <li>The Record block object</li> * <li>The "arg" argument from the load function</li> * <li>A boolean success indicator</li> * </ul> * @param {Object} scope The scope in which to call the callback * @param {Object} arg An optional argument which is passed to the callback as its second parameter. */ load: function(params, reader, loadCallback, scope, arg) { var dataProxy = this; if (dataProxy.fireEvent("beforeload", dataProxy, params) !== false) { var loadArgs = params[this.loadArgsKey] || params; // the Array or Object to build up the "dwrFunctionArgs" var dwrFunctionArgs = []; // the arguments that will be passed to the dwrFunction //dwr 用户参数 //可以为 json 字符串 ,服务器再分析,或直接 字符串数组 ,利用dwr 处理参数对应 if (loadArgs instanceof Array) { // Note: can't do a foreach loop over arrays because Ext added the "remove" method to Array's prototype. // This "remove" method gets added as an argument unless we explictly use numeric indexes. for (var i = 0; i < loadArgs.length; i++) { dwrFunctionArgs.push(loadArgs[i]); } } else { // loadArgs should be an Object for (var loadArgName in loadArgs) { dwrFunctionArgs.push(loadArgs[loadArgName]); } } //dwr 系统参数格式 dwrFunctionArgs.push({ callback: function(response) { // call readRecords verses read because read will attempt to decode the JSON, // but as this point DWR has already decoded the JSON. //读取记录 ,请服务器返回json格式 ,这里reader为ext自带的 json reader var records = reader.readRecords(response); dataProxy.fireEvent("load", dataProxy, response, loadCallback); loadCallback.call(scope, records, arg, true); }, exceptionHandler: function(message, exception) { // the event is supposed to pass the response, but since DWR doesn't provide that to us, we pass the message. dataProxy.fireEvent("loadexception", dataProxy, message, loadCallback, exception); loadCallback.call(scope, null, arg, false); } }); this.dwrFunction.apply(Object, dwrFunctionArgs); // the scope for calling the dwrFunction doesn't matter, so we simply set it to Object. } else { // the beforeload event was vetoed callback.call(scope || this, null, arg, false); } } });
store 流程
store.load { if(proxy) { proxy.load { callback:{ 调用 reader 读取 返回数据 得到 records 调用store 的一个 回调函数,参数 records } } } } store的回调函数 (records) { 更新 界面,刷新数据 }
- Store:最主要的对外交互接口,内部保存了一个数据集。
- Record:数据集里面的每一条记录。
- DataField: 定义了记录每个字段的schema。
- Proxy: 获取数据的代理。
- DataReader: 把代理读取的数据读入数据集。
Store的实现
- 内部用一个Ext .util.MixedCollection(既能够作为map进行索引,又能够作为list进行索引,并且更新数据时会触发事件,并且有一些其它功能的数据结构)作为数据集存放record。store实例的data域指向这个数据集。
- 通过proxy加载不同来源的数据,如http remote,memory data等等。
- 由于proxy加载过来的数据是异构的,所以通过不同DataReader的实现类来读入数据成为record。
- 当调用load方法时候,就会委托proxy去加载数据。
- 在data数据集中数据的数据,添加,修改,删除的时候触发事件。
Store数据加载流程简介
- 实例化一个Proxy的实现proxy。
- 实例化一个DataReader的实现reader。
- 实例化一个Store对象store。设置store的proxy与reader。
- 监听store的load事件或者datachange事件。
- 调用store.load()
- store.load会调用proxy的load方法来加载数据(各种DataSource)。并且把reader作为参数传入。
- proxy的load方法加载完数据之后,调用传入的reader的read方法,并且把数据作为参数传入。
- reader的read方法把异构数据读入成record数据集。
- proxy把reader.read方法生成的record数据集作为参数,回调store。
- store把数据集添加到或者替换原来的数据集。
- 触发load事件,触发datachange事件。
发表评论
-
模块化高扩展性的前端框架 KISSY
2013-03-14 14:58 8552模块化高扩展性的前端框架 KISSY 注:本文为 2 ... -
构建前端 DSL
2012-10-11 22:10 5285目前在传统的软件开 ... -
KISSY kisses bootstrap navbar
2012-08-03 01:12 5955看了下 bootstrap 的导航菜单,立刻非常喜欢,注意是浅 ... -
promise api 与应用场景
2012-02-07 17:34 7286promise 是 commonjs 社区中提出的异步规范,其 ... -
unified event model
2011-10-14 23:02 1749为了处理原生事件在各 ... -
转载:瀑布流布局浅析
2011-09-29 19:02 2787简介 如果你经 ... -
cross domain request
2011-09-29 18:39 2791场景 跨域请求是随着 ... -
基于多继承的树设计
2011-09-18 03:42 2204分类 树是一种常见 ... -
caja 原理 : 前端
2011-09-01 16:48 6941作为前端开放的基础安全保证,caja 是目前比较合 ... -
ie 下 cloneNode 导致的属性克隆
2011-08-24 16:10 2414这个还是很值得记下,一直存在的很大隐患终于解决,由于在 ie& ... -
just another event model
2011-06-08 20:47 2126事件模型也算是客户端兼容性的一个长期问题,早期 jquery ... -
框架 build 系统介绍
2010-07-11 01:29 1592一个复杂的类库通常都包括很多子模块( jquery@git ... -
querySelectorAll 探讨
2010-07-01 22:35 4433随着css selector engine在越来越多的java ... -
再谈 attribute
2010-06-22 11:37 2566@slideshare 原生: ... -
事件机制探讨
2010-06-21 13:54 2177由于浏览器事件机制的不兼容性,譬如最常见的注册事件差异 ... -
利用Attribute重构:业务与UI分离
2010-06-08 16:54 1538很简单的一个应用 通过按钮来限制输入范围 ,这样的话再 ... -
yui3 loader的串行加载特性
2010-06-04 12:30 1771yui3 的沙箱机制可以在 ... -
yui3下的load事件触发
2010-06-01 13:31 3162以前的一些总结:页面l ... -
理解YUI3 extension:Base.create
2010-05-31 03:01 1957YUI3中为了避免不必要的类继承层次,以及摆脱利用原型链模拟的 ... -
google WebFont Loader 源码阅读
2010-05-22 01:04 2717资料: 关于新发 ...
相关推荐
看到大家在讨论dwrproxy,这是本人修改后的.
NULL 博文链接:https://clq9761.iteye.com/blog/1001863
ExtJs中使用dwrproxy,和json来处理从数据库里查询出来的数据 其中dwrproxy还支持分页(分页功能没做),将war包下载下来后,直接放在tomcat里,然后启动tomcat就可以了 数据库方面,该项目里用的是mysql,数据文件在...
这个例子中有登录,有...表格中的数据是通过DWRProxy加载共分3中形式,用以下3中解析器来解析的: DWRJsonReader DWRArrayReader DWRXmlReader 数据完全由JAVA方法返回,由DWR动态调用,利用了Spring作为Bean的容器。
DWRproxy <br>EXT 的代理
dwrProxy.js
Ext扩展dwrproxyExt扩展dwrproxyExt扩展dwrproxyExt扩展dwrproxyExt扩展dwrproxyExt扩展dwrproxyExt扩展dwrproxyExt扩展dwrproxyExt扩展dwrproxy
ExtJs3 DWR扩展 DWRProxy、DWRTreeLoader、DWRGridProxy,经过EXT3.0版本测试! 通过DWR向Ext提供数据!非常棒的扩展!
ExtJs DWR扩展 DWRProxy、DWRTreeLoader、DWRGridProxy,经过EXT3.0版本测试! 通过DWR向Ext提供数据!非常棒的扩展!
如果使用extjs 和 dwr 进行开发,这两个js文件必不可少,所以压缩到一起,进行了保留!
dwrproxy.js 博文链接:https://cicada-it.iteye.com/blog/102949
EXT2未加入对DWR的支持,此文件是对其的扩展进而实现DWR的支持
Ext中结合dwr要用到的几个.js文件,下载后解压导入web工程中,
用EXT和DWR结合起来做工程时,在数据传输时会有点麻烦,这里提供的3个JS文件分别实现了DWR的数据代理,分页查询处理,动态树加载。并且实现了Ext.data.DWRArrayReader Ext.data.DWRXmlReader ...
EXT+DWR分页 ,前人基础修改,绝对能用 有问题的大家相互交流, 具体使用请参考我的文章EXT+DWR分页
NULL 博文链接:https://redboy5711.iteye.com/blog/259913
一,在Ext中直接使用DWR 1,PoJO的Manager类为 代码如下:public class CustomerManagerImpl extends HibernateDaoSupport implements CustomerManager { public PageModel allCustomers() { PageModel pageModel = ...
该工程在MyEclipse中可以无错的导入...利用到了PagingDWRProxy,DWRProxy等。 是在以前发的一个例子的基础上增加了数据库,数据不是硬编码的,使用了Hibernate.页面的原型则利用刘长炯老师的例子,这里感谢刘长炯老师!