论坛首页 Java企业应用论坛

一个使用<ww:action />获取数据并显示的问题。

浏览 3540 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2006-10-23  
在程序中为获得所有Teacher的list并显示在jsp页面中,打算通过<ww:action/>来实现取数据,运行起来可以正常显示数据,这个没有问题。

现在问题是当所在的jsp页面提交后,我配置了validators,validation没通过,将返回该jsp页面,这个时候<ww:action/>没有起作用,数据没有显示出来。

请问该如何处理,才能确保返回该jsp页面时,数据依然能够显示。

谢谢!

产生list列表的action:
package net.ocas.action.util;

import java.util.ArrayList;
import java.util.List;

import net.ocas.service.CourseService;
import net.ocas.service.TeacherService;

import com.opensymphony.xwork.ActionSupport;

public class ListAction extends ActionSupport{
	
	private List list=new ArrayList();

	public String getAllCourses() throws Exception{
		CourseService cs=CourseService.getInstance();
		list=cs.findAll();
		return SUCCESS;
	}
	
	public String getCoursesWithOutTeacher() throws Exception{
		CourseService cs=CourseService.getInstance();
		list=cs.findCoursesWithOutTeacher();
		return SUCCESS;
	}

	
	public String getAllTeachers() throws Exception{
		TeacherService ts=TeacherService.getInstance();
		list=ts.findAll();
		return SUCCESS;
	}
	
	
	public List getList() {
		return list;
	}

	public void setList(List list) {
		this.list = list;
	}
}


xwork.xml的配置片断:
<package name="manage" extends="webwork-default"
		namespace="/manage">
		
		<action name="addCourse"
			class="net.ocas.action.AddCourseAction">
			<result name="success">/manage/add_course.jsp</result>
			<result name="input">/manage/add_course.jsp</result>
			<interceptor-ref name="params" />
			<interceptor-ref name="validationWorkflowStack" />
		</action>
</package>

<package name="util" extends="webwork-default" namespace="/util">

		<action name="listFactory"
			class="net.ocas.action.util.ListAction">
			<result name="success">/login.jsp</result>
		</action>


	</package>



jsp页面的代码片断:
<ww:form action="addCourse" method="post">
	<ww:textfield label="Course code" name="course.courseCode" size="30"/>
<ww:action namespace="/util" name="listFactory!getAllTeachers" id="teachers" executeResult="false"/>
	
	<ww:select label="Teacher" 
		name="teacherId" 
		list="#teachers.list" 
		listKey="id"
       	listValue="%{firstName + ' ' + lastName}" 
		size="10" />
   发表时间:2007-01-20  
我也遇到同样的问题,找到了答案,回你一下english这是原文
---------------------------
URL:http://www.nabble.com/Re:-ww:action-tag-not-working-with-validation--p2574193.html#30862

Your validation can work, because only not validate action (ww:action) for populating list. Action for submit form should have validate interceptor enabled. I have this problem too.

I have something like this:

<!-- Default interceptor stack. --> 
                <default-interceptor-ref name="defaultStack" /> 

                <action name="saveForm" class="saveUzytkownika"> 
                        <result name="success" type="redirect-action"> 
                                ... 
                        </result> 
                        <result name="input" type="dispatcher"> 
                                ... 
                        </result> 
                </action> 

                <action name="populateList" class="poluateListAction"> 
                        <interceptor-ref name="basicStack" /> 
                </action> 
0 请登录后投票
论坛首页 Java企业应用版

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