前端为ExtJS 4.2
服务端为extdirectspring, extdirectspring的配置如下,
/** * Configuration class to configure different aspects of extdirectspring. */ @Bean public ch.ralscha.extdirectspring.controller.Configuration configuration(){ ch.ralscha.extdirectspring.controller.Configuration configuration=new ch.ralscha.extdirectspring.controller.Configuration(); configuration.setBatchedMethodsExecutionPolicy(BatchedMethodsExecutionPolicy.SEQUENTIAL); configuration.setEnableBuffer(false); return configuration; }
configuration.setEnableBuffer(false)表明Ext不会缓存一批request作为一次发送到服务器端,但是发现设置后不工作,原因,ExtJS4.2里有一个bug,4.2以后的应该修复了,这里拿ext-all-debug.js来说明需要修改的地方,很简单,我已经标明,你只有注释掉一行,新添加一行即可。
queueTransaction: function(transaction) { var me = this, enableBuffer = me.enableBuffer; if (transaction.form) { me.sendFormRequest(transaction); return; } if (typeof transaction.timeout !== 'undefined') { me.sendRequest(transaction); return; } //新添加 me.callBuffer.push(transaction); if (enableBuffer) { //注释掉该行 //me.callBuffer.push(transaction); if (!me.callTask) { me.callTask = new Ext.util.DelayedTask(me.combineAndSend, me); } me.callTask.delay(Ext.isNumber(enableBuffer) ? enableBuffer : 10); } else { me.combineAndSend(); } },