• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

validation fron both ActionForm and struts inbuilt validtaion

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
can i use validation fron both ActionForm and struts inbuilt validtaion.
i mean in struts config i have validation=true so i will get some validaion on that. at the same time i also want to use the errors which i get from my validate method of Actionfrom bean.
At a time only one validation works
can i use both validations at same time. as i dont want to use Custom validations.
we are writing ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {

so is there a way out to find errors from mapping.
Thank you in advance.

Nishita
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nishita,

First of all are u clear with validate() method in ActionForm and the validate = true attrib value in struts-config value.

reason being both mean the same.

it works like this if in Action tag u mention validate = 'true' then the corresponding ActionForms validate() method is called where u would implement ur validation logic which returns ActionErrors .

with this i think if u mention validate = 'true' then only ur validate method defined in the ActionForm is invoked other wise it does not invoke it at all.
 
Nishita Jain
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,
i might have not describe myself well. what i did was in struts-config file i wrote validation=true an in validation.xml
i have written
<form name="QuestionBean">

<field property="questionText"
depends="required,maxlength">
<arg0 key="prompt.questionText"/>

<arg1 key="${var:maxlength}" name="maxlength"
resource="false"/>

<var>
<var-name>maxlength</var-name>
<var-value>50</var-value>
</var>
</field>
</form>

so it will do validation even if i dont write write validate methis in actionForm page. so now i want to do validation using both validation.xml and Actionfrom validate method.
am i clear now?

Thanks
-Nishita
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure you can do this. In your form should extend a class such as ValidatorForm. Override the validation method and either call super.validate some place in your code. Such as this:


- Brent
 
Nishita Jain
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello Brent,
Thanks for solving my problem

-Nishita
 
reply
    Bookmark Topic Watch Topic
  • New Topic