- 浏览: 1475199 次
- 性别:
- 来自: 上海
-
文章分类
最新评论
-
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 8734模块化高扩展性的前端框架 KISSY 注:本文为 2 ... -
构建前端 DSL
2012-10-11 22:10 5435目前在传统的软件开 ... -
KISSY kisses bootstrap navbar
2012-08-03 01:12 6104看了下 bootstrap 的导航菜单,立刻非常喜欢,注意是浅 ... -
promise api 与应用场景
2012-02-07 17:34 7453promise 是 commonjs 社区中提出的异步规范,其 ... -
unified event model
2011-10-14 23:02 1799为了处理原生事件在各 ... -
转载:瀑布流布局浅析
2011-09-29 19:02 2899简介 如果你经 ... -
cross domain request
2011-09-29 18:39 2876场景 跨域请求是随着 ... -
基于多继承的树设计
2011-09-18 03:42 2285分类 树是一种常见 ... -
caja 原理 : 前端
2011-09-01 16:48 7140作为前端开放的基础安全保证,caja 是目前比较合 ... -
ie 下 cloneNode 导致的属性克隆
2011-08-24 16:10 2505这个还是很值得记下,一直存在的很大隐患终于解决,由于在 ie& ... -
just another event model
2011-06-08 20:47 2181事件模型也算是客户端兼容性的一个长期问题,早期 jquery ... -
框架 build 系统介绍
2010-07-11 01:29 1676一个复杂的类库通常都包括很多子模块( jquery@git ... -
querySelectorAll 探讨
2010-07-01 22:35 5460随着css selector engine在越来越多的java ... -
再谈 attribute
2010-06-22 11:37 2710@slideshare 原生: ... -
事件机制探讨
2010-06-21 13:54 2267由于浏览器事件机制的不兼容性,譬如最常见的注册事件差异 ... -
利用Attribute重构:业务与UI分离
2010-06-08 16:54 1606很简单的一个应用 通过按钮来限制输入范围 ,这样的话再 ... -
yui3 loader的串行加载特性
2010-06-04 12:30 1833yui3 的沙箱机制可以在 ... -
yui3下的load事件触发
2010-06-01 13:31 3277以前的一些总结:页面l ... -
理解YUI3 extension:Base.create
2010-05-31 03:01 2018YUI3中为了避免不必要的类继承层次,以及摆脱利用原型链模拟的 ... -
google WebFont Loader 源码阅读
2010-05-22 01:04 2806资料: 关于新发 ...
相关推荐
"Ext的DWRProxy应用事例"这个主题聚焦于如何利用Direct Web Remoting (DWR) 和 ExtJS 的DWRProxy组件进行异步数据通信。 DWR是一种JavaScript框架,它允许Web页面与Java后台服务器进行实时、安全、跨域的数据交换。...
《DWRProxy.js:在ExtJS中的应用与实践》 DWRProxy.js是Direct Web Remoting (DWR)框架中的一个重要组成部分,它在JavaScript和Java之间建立起桥梁,使得Web应用程序可以方便地进行异步通信。DWR允许前端JavaScript...
DWRproxy,全称Direct Web Remoting Proxy,是EXT框架中的一个重要组成部分,主要用来实现浏览器与服务器之间的异步通信。EXT是一个强大的JavaScript库,用于构建富客户端应用,而DWRproxy则是EXT与服务器端交互的...
ExtJs中使用dwrproxy,和json来处理从数据库里查询出来的数据 其中dwrproxy还支持分页(分页功能没做),将war包下载下来后,直接放在tomcat里,然后启动tomcat就可以了 数据库方面,该项目里用的是mysql,数据文件在...
1. **DWRProxy**: DWRProxy是ExtJs中的一个类,它作为DWR和ExtJs之间的桥梁,使得ExtJs可以利用DWR的远程调用功能。通过配置DWRProxy,开发者可以定义哪些服务器端的方法可供JavaScript调用,并控制这些调用的参数和...
这个例子中有登录,有...表格中的数据是通过DWRProxy加载共分3中形式,用以下3中解析器来解析的: DWRJsonReader DWRArrayReader DWRXmlReader 数据完全由JAVA方法返回,由DWR动态调用,利用了Spring作为Bean的容器。
dwrProxy.js
标题中的"dwrtproxy"和"dwrproxy.js"指的是DWR中的一个关键组件——DWR Proxy,而"dwrtreeloader"和"DWRTreeLoader.js"则涉及ExtJS中的TreePanel与DWR的集成,用于加载和展示树形结构数据。 **1. DWR(Direct Web ...
EXTJS 3 整合DWR (DWRProxy、DWRTreeLoader、DWRGridProxy) 是一个在EXTJS 3.0版本中实现的重要技术整合,它将DWR(Direct Web Remoting)的强大功能引入到EXTJS的前端框架中,以实现更高效的数据交互。EXTJS是一个...
Ext扩展dwrproxyExt扩展dwrproxyExt扩展dwrproxyExt扩展dwrproxyExt扩展dwrproxyExt扩展dwrproxyExt扩展dwrproxyExt扩展dwrproxyExt扩展dwrproxy
本篇文章将深入探讨在Ext框架下,与DWR(Direct Web Remoting)集成所使用的三个关键JavaScript文件:`dwrproxy.js`、`DWRTreeLoader.js`和`PagingDWRProxy.js`。这些文件对于实现动态数据交互和页面组件的高效加载...
在这个例子中,我们创建了一个使用DWRProxy的Store,DWRProxy允许我们在后台Java方法和前端JavaScript之间进行透明的数据交换。DWR方法`YourDWRMethod`应该接受分页参数(start和limit),并返回包含数据和总记录数...
dwrproxy.js 博文链接:https://cicada-it.iteye.com/blog/102949
EXT2未加入对DWR的支持,此文件是对其的扩展进而实现DWR的支持
用EXT和DWR结合起来做工程时,在数据传输时会有点麻烦,这里提供的3个JS文件分别实现了DWR的数据代理,分页查询处理,动态树加载。并且实现了Ext.data.DWRArrayReader Ext.data.DWRXmlReader ...
EXT+DWR分页 ,前人基础修改,绝对能用 有问题的大家相互交流, 具体使用请参考我的文章EXT+DWR分页
本主题将深入探讨如何在ExtJS中使用DWR的代理(DWRProxy)以及树结构加载器(DWRTreeLoader),以便于在ExtJS组件,特别是树形控件中有效地利用DWR的功能。 首先,让我们了解DWRProxy。DWRProxy是ExtJS中用于与DWR...
具体来说,`dwrproxy.js`可能是这个示例的核心文件,它实现了EXT和DWR之间的代理配置和通信。 在EXT中,DWR通常被用来作为后端数据源,为EXT的组件如Grid、Tree或Form提供数据。`dwrproxy.js`文件可能包含了以下...