论坛首页 入门技术论坛

Extjs 两个JsonStore 使用同一个url(action)时问题

浏览 11329 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (8) :: 隐藏帖 (0)
作者 正文
   发表时间:2009-09-25  
我也用到,
但是我是对文件操作
好像有同样问题
0 请登录后投票
   发表时间:2009-09-27  
先把数据通过AJAX得到,然后用new Ext.data.Store实现本地化数据,就不会出现这个问题,楼主试试
0 请登录后投票
   发表时间:2009-09-27  
谢谢你的回复
你的意思是不是,一次把需要的数据都取出来,然后在本地new 多个store。
这种方式我也想过,不过这样做有点问题。

问题:
1、在store需要单独提交,我没必要每次都要把全部的数据都取出来。这样就失去ajax的优越性了。
2、一次取出,如果这些store在多个grid中使用(一个页面有多个Grid),我还要传来传去。比较麻烦,不如什么地方使用什么地方后台取数。
3、有些store需要根据条件动态获得(一次取出所有条件的数据放在客户端不现实),本地store不好满足。
0 请登录后投票
   发表时间:2009-09-27  
你用的是google的jsonPlugin for struts2吧,getXx()会被它当作一个property get方法调用的。
如果你在方法里面设置了断点,就会发现,每次总有个方法被调了两次。


0 请登录后投票
   发表时间:2009-09-28   最后修改:2009-09-28

没有使用jsonPlugin

我直接使用PrintWriter 输出,action返回null。
PrintWriter out = this.servletResponse.getWriter();
out.write(str);
// 清空缓存
out.flush();
// 关闭流
out.close();
在一个action中有多个方法一起执行。
我使用sumObjAction!showSumObjByPage.action   的方式。
0 请登录后投票
   发表时间:2009-10-11  
piaoyaohou 写道
困扰了我很久的问题,在网上找找,也没找解决办法。

问题是,我在一个页面上有两个ComboBox,数据来源是同一个action(我使用的struts2)
还是看看代码吧
var store_comBox_volt = new Ext.data.JsonStore({
         url : "dropAction!getVoltDrop.action",
	root : 'volt',
	fields : ['id', 'name']
。。。。。。。。。。。。

后台处理正常,但在页面上不显示。不知道什么原因。后来,在网上看到:EXT用定时检查的方法处理连接是否正常结束的问题,每50毫秒一次。
我就在store_comBox_org上加一个定时器。
setTimeout(function(){store_comBox_volt.load()},100);
这样就正常了。

我也遇到这问题,而且我是两个树同一个Action,并发下,
第一树传param.id=12,第二树传param.name='tom',可是有时候看它打印出来的Sql把两个条件并到一块了,成了
where id=12 and name='tom' 我郁闷了。。Action里面的是挺正常的,
若有答案了,烦楼主短信告知下,感谢 。
0 请登录后投票
   发表时间:2009-10-12  
我为什么没有出现你们的问题,能不能把整个js,还有Action贴出来,大家研究一下
0 请登录后投票
   发表时间:2009-10-13   最后修改:2009-10-13
困扰了我很久的问题,在网上找找,也没找解决办法。

问题是,我在一个页面上有两个ComboBox,数据来源是同一个action(我使用的struts2)
还是看看代码吧
var store_comBox_volt = new Ext.data.JsonStore({
         url : "dropAction!getVoltDrop.action",
	root : 'volt',
	fields : ['id', 'name']
	});
store_comBox_volt.load()
var comBox_volt = new Ext.form.ComboBox({ // combobox
	fieldLabel : '电压等级',
	displayField : 'key',
	width:'50',
	mode : 'local',
	store : store_comBox_volt,
	displayField : 'name',
	valueField : 'id',
	forceSelection : true,
	triggerAction : 'all',
	selectOnFocus : true,
	typeAhead : true
	});


 var store_comBox_org = new Ext.data.JsonStore({
						url : "dropAction!getOrgsDrop.action",
	root : 'orgs',
	fields : ['id', 'name']
	});	
store_comBox_org.load();
var comBox_org = new Ext.form.ComboBox({ // combobox
	fieldLabel : '管理单位',
	displayField : 'key',
	mode : 'local',
	store : store_comBox_org,
	displayField : 'name',
	forceSelection : true,
	triggerAction : 'all',
	selectOnFocus : true,
	typeAhead : true
	 });

js代码已经贴出

我再把action贴出来。

@SuppressWarnings("unchecked")
public class DropAction extends BaseActionSupport {
	private DropServImpl dropServ;

	public void setDropServ(DropServImpl dropServ) {
		this.dropServ = dropServ;
	}

	/**
	 * 管理单位下拉
	 * 
	 * @return
	 * @throws Exception
	 */
	public String getOrgsDrop() throws Exception {
		try {
			String type = this.servletRequest.getParameter("type");
			// 调用业务
			List<TpParaOrgs> list = dropServ.getOrgDropList();
			JSONArray jsonArray = new JSONArray();
			Iterator iterator = list.iterator();
			while (iterator.hasNext()) {
				TpParaOrgs org = (TpParaOrgs) iterator.next();
				Map map = new HashMap();
				map.put("id", org.getOrgNo());
				map.put("name", org.getOrgName());
				jsonArray.add(map);
			}
			super.outJsonArray(jsonArray, "orgs");

		} catch (Exception e) {
			logger.debug("执行失败!" + e);
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * 电压等级下拉
	 * 
	 * @return
	 * @throws Exception
	 */
	public String getVoltDrop() throws Exception {
		try {
			List<TpParaVolt> list = dropServ.getVoltDropList();
			JSONArray jsonArray = new JSONArray();
			Iterator iterator = list.iterator();
			while (iterator.hasNext()) {
				TpParaVolt volts = (TpParaVolt) iterator.next();
				Map map = new HashMap();
				map.put("id", volts.getVoltCode());
				map.put("name", volts.getVoltName());
				jsonArray.add(map);
			}
			super.outJsonArray(jsonArray, "volt");

		} catch (Exception e) {
			logger.debug("getVoltDrop执行失败!" + e);
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * 运行状态下拉
	 * 
	 * @return
	 * @throws Exception
	 */
	public String getRunStatusDrop() throws Exception {
		try {
			List<TpParaDetail> list = dropServ.getRunStatusDropList();
			JSONArray jsonArray = new JSONArray();
			Iterator iterator = list.iterator();
			while (iterator.hasNext()) {
				TpParaDetail paraDetail = (TpParaDetail) iterator.next();
				Map map = new HashMap();
				map.put("id", paraDetail.getId().getId());
				map.put("name", paraDetail.getName());
				jsonArray.add(map);
			}
			super.outJsonArray(jsonArray, "runStat");

		} catch (Exception e) {
			logger.debug("getRunStatusDrop执行失败!" + e);
			e.printStackTrace();
		}
		return null;
	}


}

0 请登录后投票
   发表时间:2010-03-17  
自己解决了,使用原型模式就可以了。

我使用spring管理struts2的action
在spring配置文件中添加

scope="prototype"
0 请登录后投票
   发表时间:2010-03-19  
知道为什么么?
0 请登录后投票
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics