You'll also need the validation plugin [1], and you  might want to read the
validation docs as well [2].

Dave

[1]
http://struts.apache.org/1.3.10/userGuide/building_view.html#form_validation
<http://struts.apache.org/1.3.10/userGuide/building_view.html#form_validation>
[2] http://struts.apache.org/1.3.10/faqs/validator.html

2010/11/18 Paweł Wielgus <poulw...@gmail.com>

> Hi Anjib,
> have You set validate=true in struts-config.xml for this action like below?
>
> < action path="/path/to/action"
> type="com.UploadAction"
> name="myTestForm"
> input="tile.definition"
> validate="true" >
>
> Best greetings,
> Paweł Wielgus.
>
>
> 2010/11/18 Anjib Mulepati <anji...@hotmail.com>:
> > Hi everyone
> >
> > I got confuse with the call of ActionForm in Struts 1.3.8
> >
> > If I have Form as follow with validate() method
> >
> > public class MyTestForm extends org.apache.struts.action.ActionForm {
> >
> >     String myTestString;
> >
> >    public MyTestForm() {
> >        super();
> >    }
> >
> >    public String getMyTestString() {
> >        return myTestString;
> >    }
> >
> >    public void setMyTestString(String newString) {
> >        this.myTestString =newString;
> >    }
> >
> >    @Override
> >    public ActionErrors validate(ActionMapping mapping, HttpServletRequest
> > request) {
> >        ActionErrors errors = new ActionErrors();
> >        //do validation of myTestString
> >        return errors;
> >   }
> >
> > }
> >
> > And I have Action class as
> >
> > public class UploadAction extends org.apache.struts.action.Action {
> >
> >    public ActionForward execute(ActionMapping mapping, ActionForm form,
> >            HttpServletRequest request, HttpServletResponse response)
> >            throws IOException, ServletException {
> >                        MyTestForm myForm = (MyTestForm) form;
> >                        //Other operation
> >   }
> > }
> >
> > Now when I debug with debugging point at both validate() and execute()
> > method's first statement what i found is the control never goes to
> > validate() method. I was guessing control should go to validate method
> first
> > then only to execute method. In other word my input was never validated.
> >
> > What I am doing wrong? Can anyone help me out in this?
> >
> > Thanks in advance
> > Anjib
> >
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

Reply via email to