You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by rocie <ro...@yahoo.com.cn> on 2005/03/24 03:44:26 UTC
How can I invoke the validate() method in DispatchAction
hello,
Here is my code :
-----------------------struts-test-conf.xml-----------------------
<form-beans>
<form-bean name="testForm" type = "goni.test.Test" />
</form-beans>
<action path="/test" type="goni.test.TestAction" name="testForm" scope="request" parameter="op">
<forward name="home" path="home" />
<forward name="pre_insert" path="pre_insert" />
<forward name="pre_update" path="pre_update" />
<forward name="list" path="list" />
<forward name="get" path="get" />
</action>
-----------------------TestAction-----------------------
public ActionForward home(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//...
return mapping.findForward("home");
}
public ActionForward pre_insert(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//...
return mapping.findForward("pre_insert");
}
public ActionForward insert(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//...
}
public ActionForward pre_update(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//...
}
public ActionForward update(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//...
}
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//...
}
public ActionForward list(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//...
}
public ActionForward get(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//...
}
The TestAction extends the DispacthAction , and the Test extends the ValidateForm. I can use test.do?op=pre_insert to show a jsp page with a form and if it is submitted, the test.do?op=insert will be execute,the validate() method will be invoked ,then the data in the form will be inserted into the database.If I execute the insert and update methods , the validate() method will be invoked,I wish when I execute the other methods , the validate() won't be invoke, how to ?
thanks!
---------------------------------
Do You Yahoo!?
150万曲MP3疯狂搜,带您闯入音乐殿堂
美女明星应有尽有,搜遍美图、艳图和酷图
1G就是1000兆,雅虎电邮自助扩容!