You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by su...@tcs.com on 2004/02/11 04:21:51 UTC

Validation.xml

Hi Guys,

        I've three screens assume that they are add, modify and view 
screens. I would like to use same form for all the screens.
But the problem is, each one of the screens has a different set of 
validation rules, how do i achieve this? Somewhere, i read that it
is possible to use action path names in validation.xml. Can anyone post a 
sample validation.xml?



Thanks and Regards

O. Subramaniam 
Tata Consultancy Services
Mailto: subramaniam.o@tcs.com
Website: http://www.tcs.com

Re: Validation.xml

Posted by Joe Germuska <Jo...@Germuska.com>.
At 10:29 AM +0530 2/11/04, subramaniam.o@tcs.com wrote:
>Hi,
>O.k I'll try VaidatorActionForm. could you plz tell me whether the 
>following line is correct!
>
>Validation.xml
><form-set>
>         <form input="\path" property="A" depends="required" />
></form-set>

no, form properties are "field" elements within the "form" element.

Have a look at http://jakarta.apache.org/struts/userGuide/dev_validator.html

There are also several links at the bottom to more detailed 
information, including sample chapters from two Struts books.

Joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
       "Imagine if every Thursday your shoes exploded if you tied them 
the usual way.  This happens to us all the time with computers, and 
nobody thinks of complaining."
             -- Jef Raskin

Re: Validation.xml

Posted by su...@tcs.com.
Hi,
O.k I'll try VaidatorActionForm. could you plz tell me whether the 
following line is correct!

Validation.xml
<form-set>
        <form input="\path" property="A" depends="required" />
</form-set>

Thanks and Regards

O. Subramaniam 
Tata Consultancy Services
Mailto: subramaniam.o@tcs.com
Website: http://www.tcs.com



Joe Germuska <Jo...@Germuska.com> 
02/11/2004 10:17 AM

Please respond to
"Struts Users Mailing List" <st...@jakarta.apache.org>


To
"Struts Users Mailing List" <st...@jakarta.apache.org>
cc

Subject
Re: Validation.xml






At 9:52 AM +0530 2/11/04, subramaniam.o@tcs.com wrote:
>Hi,
>
>All my forms extend ValidatorForm,  should i change it to 
DynaValidatorForm?
>is this is the only option?

Whoops.  No; just extend ValidatorActionForm instead; it's the same model.

http://jakarta.apache.org/struts/api/org/apache/struts/validator/ValidatorActionForm.html


I haven't had to actually write a form class in quite a while, so I 
assumed that you were using DynaForms too.

Joe

-- 
Joe Germuska 
Joe@Germuska.com 
http://blog.germuska.com 
       "Imagine if every Thursday your shoes exploded if you tied them 
the usual way.  This happens to us all the time with computers, and 
nobody thinks of complaining."
             -- Jef Raskin
ForwardSourceID:NT00002526 

Re: Validation.xml

Posted by Joe Germuska <Jo...@Germuska.com>.
At 9:52 AM +0530 2/11/04, subramaniam.o@tcs.com wrote:
>Hi,
>
>All my forms extend ValidatorForm,  should i change it to DynaValidatorForm?
>is this is the only option?

Whoops.  No; just extend ValidatorActionForm instead; it's the same model.

http://jakarta.apache.org/struts/api/org/apache/struts/validator/ValidatorActionForm.html

I haven't had to actually write a form class in quite a while, so I 
assumed that you were using DynaForms too.

Joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
       "Imagine if every Thursday your shoes exploded if you tied them 
the usual way.  This happens to us all the time with computers, and 
nobody thinks of complaining."
             -- Jef Raskin

Re: Validation.xml

Posted by su...@tcs.com.
Hi,

All my forms extend ValidatorForm,  should i change it to 
DynaValidatorForm?
is this is the only option?


Thanks and Regards

O. Subramaniam 
Tata Consultancy Services
Mailto: subramaniam.o@tcs.com
Website: http://www.tcs.com



Joe Germuska <Jo...@Germuska.com> 
02/11/2004 09:37 AM

Please respond to
"Struts Users Mailing List" <st...@jakarta.apache.org>


To
"Struts Users Mailing List" <st...@jakarta.apache.org>
cc

Subject
Re: Validation.xml






At 8:51 AM +0530 2/11/04, subramaniam.o@tcs.com wrote:
>Hi Guys,
>
>         I've three screens assume that they are add, modify and view 
>screens. I would like to use same form for all the screens.
>But the problem is, each one of the screens has a different set of 
>validation rules, how do i achieve this? Somewhere, i read that it
>is possible to use action path names in validation.xml. Can anyone 
>post a sample validation.xml?

Basically, you just use a different form class in the struts-config:
http://jakarta.apache.org/struts/api/org/apache/struts/validator/DynaValidatorActionForm.html


When this class's validate method is called, it uses that action's 
path instead of form's name.

Joe

-- 
Joe Germuska 
Joe@Germuska.com 
http://blog.germuska.com 
       "Imagine if every Thursday your shoes exploded if you tied them 
the usual way.  This happens to us all the time with computers, and 
nobody thinks of complaining."
             -- Jef Raskin
ForwardSourceID:NT0000251A 

Re: Validation.xml

Posted by Joe Germuska <Jo...@Germuska.com>.
At 8:51 AM +0530 2/11/04, subramaniam.o@tcs.com wrote:
>Hi Guys,
>
>         I've three screens assume that they are add, modify and view 
>screens. I would like to use same form for all the screens.
>But the problem is, each one of the screens has a different set of 
>validation rules, how do i achieve this? Somewhere, i read that it
>is possible to use action path names in validation.xml. Can anyone 
>post a sample validation.xml?

Basically, you just use a different form class in the struts-config:
http://jakarta.apache.org/struts/api/org/apache/struts/validator/DynaValidatorActionForm.html

When this class's validate method is called, it uses that action's 
path instead of form's name.

Joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
       "Imagine if every Thursday your shoes exploded if you tied them 
the usual way.  This happens to us all the time with computers, and 
nobody thinks of complaining."
             -- Jef Raskin

RE: Validation.xml

Posted by Marco Mistroni <mm...@waersystems.com>.
Hi,
            Easiest thing is to handle this in the validate method of
your action form, provided that
You have a parameter in your Action form that can tells you if you are
adding modifying or viewing..
 
Regards
            marco
 
-----Original Message-----
From: subramaniam.o@tcs.com [mailto:subramaniam.o@tcs.com] 
Sent: 11 February 2004 03:22
To: struts-user@jakarta.apache.org
Subject: Validation.xml
 

Hi Guys, 

        I've three screens assume that they are add, modify and view
screens. I would like to use same form for all the screens. 
But the problem is, each one of the screens has a different set of
validation rules, how do i achieve this? Somewhere, i read that it 
is possible to use action path names in validation.xml. Can anyone post
a sample validation.xml? 



Thanks and Regards

O. Subramaniam 
Tata Consultancy Services
Mailto: subramaniam.o@tcs.com
Website: http://www.tcs.com