struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gupta, Sahil" <sagu...@webmd.net>
Subject RE: How can I invoke the validate() method in DispatchAction
Date Thu, 24 Mar 2005 13:45:02 GMT
override the validate method with your own code to check if the action is
the one that you want to invoke the validate for and do validation only in
those cases. Alternately, create a new dispatch action for the methods you
want validated and for those you do not want validation and call the 2
seperately.

Sahil

-----Original Message-----
From: rocie [mailto:rociego@yahoo.com.cn]
Sent: Wednesday, March 23, 2005 9:44 PM
To: dev@struts.apache.org
Subject: 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兆,雅虎电邮自助扩容!

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message