论坛首页 Java企业应用论坛

webwork 返回input后数据显示问题

浏览 3347 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2006-10-23  
我有一个注册用户的界面,里面有几个选择框是从数据库中取得的数据,

	private List countryList;

	private User user = new User();

	public String execute() throws Exception {
		userManager.save(user);
		return SUCCESS;
	}

         这里是为了刚进入注册页面时,需要从数据库中取得国家的列表,还有其他从数据库中取得的数据
	public String doInput() throws Exception {
                  ......
		countryList = commonManager.findCountryList();
		return INPUT;
	}

         这里是为了后台服务器需要一些验证,如果出错的话,返回注册页面,而问题也就是这里,
           我又需要重新去数据库查询一把数据,然后在页面显示,可是,总觉得这样不合理,是不是有
           更合理的方法呢?
	public void validate() {
                  ......
	         addFieldError("", Msg.SEL_JOINSTAT);
		
		if (hasFieldErrors()) {
			countryList = commonManager.findCountryList();

		}
	}


在验证不通过时,我怎样可以不再去数据库查询呢?因为刚进去注册页面的时候已经查询过了,再去查询一把,加大了数据库的负担了。各位大佬怎么做的呢?
   发表时间:2006-10-24  
实现Preparable interface
在prepare()方法里面做
countryList = commonManager.findCountryList();
0 请登录后投票
   发表时间:2006-10-24  
对于web框架的方法调用流程不是很清楚的情况下,另外一个办法是,保持一个request范围的flag(比如_countryInitialized)

0 请登录后投票
   发表时间:2006-12-15  
Readonly 写道
实现Preparable interface
在prepare()方法里面做
countryList = commonManager.findCountryList();


正解,我一般还会加上 clearErrorsAndMessages()这个方法。
0 请登录后投票
论坛首页 Java企业应用版

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