You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Anjib Mulepati <an...@hotmail.com> on 2010/11/18 16:51:45 UTC

Clear up concept of validation() call

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





Re: Clear up concept of validation() call

Posted by Anjib Mulepati <an...@hotmail.com>.
Thanks Pawel

That was the problem. I have validate="false". don't know why I did 
that? :)
And I guess default value is true for this right?

Thanks again
Anjib

On 11/18/2010 11:02 AM, Paweł Wielgus wrote:
> 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<an...@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-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>


Re: Clear up concept of validation() call

Posted by Anjib Mulepati <an...@hotmail.com>.
Sure Dave I will look into these docs.
Thanks
Anjib

On 11/18/2010 11:12 AM, Dave Newton wrote:
> 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<po...@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<an...@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-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>


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


Re: Clear up concept of validation() call

Posted by Dave Newton <da...@gmail.com>.
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 <po...@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 <an...@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-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Clear up concept of validation() call

Posted by Paweł Wielgus <po...@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 <an...@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-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org