You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Griffith, Michael *" <Mi...@fda.hhs.gov> on 2010/04/16 04:31:38 UTC

How to reuse field validators?

Hello all, 
 
I am not clear on how to reuse a field validator that doesn't share a
common package or action/alias.  I have package
 
...struts.admin/
...struts/application/
 
with namespaces /admin and /application respectively.  I have a model
object with a validator <modelClass>-validator.xml in the /application
package that I need to reuse in the admin package.  What's the best way
to reuse the validator without repeating it?

Thanks in Advance, 

MG

RE: How to reuse field validators?

Posted by "Griffith, Michael *" <Mi...@fda.hhs.gov>.
>>  you must expose you model directly.

I'm not sure what you mean by that... Can you restate?

MG

-----Original Message-----
From: Lukasz Lenart [mailto:lukasz.lenart@googlemail.com] 
Sent: Friday, April 16, 2010 9:53 AM
To: Griffith, Michael *
Cc: Struts Users Mailing List
Subject: Re: How to reuse field validators?

W dniu 16 kwietnia 2010 16:27 użytkownik Griffith, Michael * <Mi...@fda.hhs.gov> napisał:
> Currently the xml file is in the package with the struts action.  I this this is where my problem lies, should it be in the model package?

Yes, and you must expose you model directly.


Regards
--
Łukasz
http://www.lenart.org.pl/
Kapituła Javarsovia 2010
http://javarsovia.pl

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


Re: How to reuse field validators?

Posted by Lukasz Lenart <lu...@googlemail.com>.
W dniu 16 kwietnia 2010 16:27 użytkownik Griffith, Michael *
<Mi...@fda.hhs.gov> napisał:
> Currently the xml file is in the package with the struts action.  I this this is where my problem lies, should it be in the model package?

Yes, and you must expose you model directly.


Regards
-- 
Łukasz
http://www.lenart.org.pl/
Kapituła Javarsovia 2010
http://javarsovia.pl

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


RE: How to reuse field validators?

Posted by "Griffith, Michael *" <Mi...@fda.hhs.gov>.
Currently the xml file is in the package with the struts action.  I this this is where my problem lies, should it be in the model package?

MG 

-----Original Message-----
From: Lukasz Lenart [mailto:lukasz.lenart@googlemail.com] 
Sent: Friday, April 16, 2010 9:26 AM
To: Griffith, Michael *
Subject: Re: How to reuse field validators?

W dniu 16 kwietnia 2010 14:51 użytkownik Griffith, Michael * <Mi...@fda.hhs.gov> napisał:
> I want to reuse the field validations in <modelClass>-validator.xml in two different Action classes in two different packages and different namespaces. Is there a way to do that without copying the XML file?

Your model validation should work, if you are using the same model in different actions. Maybe the name is wrong -> <modelClass>-validation.xml?


Regards
--
Łukasz
http://www.lenart.org.pl/
Kapituła Javarsovia 2010
http://javarsovia.pl

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


RE: How to reuse field validators?

Posted by "Griffith, Michael *" <Mi...@fda.hhs.gov>.
Maybe I didn't express my problem correctly. The @SkipValidation annotation marks an Action method not to be validated. 

I want to reuse the field validations in <modelClass>-validator.xml in two different Action classes in two different packages and different namespaces. Is there a way to do that without copying the XML file?

MG

-----Original Message-----
From: Lukasz Lenart [mailto:lukasz.lenart@googlemail.com] 
Sent: Friday, April 16, 2010 12:13 AM
To: Struts Users Mailing List
Subject: Re: How to reuse field validators?

2010/4/16 Griffith, Michael * <Mi...@fda.hhs.gov>:
> Hello all,
>
> I am not clear on how to reuse a field validator that doesn't share a 
> common package or action/alias.  I have package
>
> ...struts.admin/
> ...struts/application/
>
> with namespaces /admin and /application respectively.  I have a model 
> object with a validator <modelClass>-validator.xml in the /application 
> package that I need to reuse in the admin package.  What's the best 
> way to reuse the validator without repeating it?

You can add annotation @SkipValidation


Regards
--
Łukasz
http://www.lenart.org.pl/
Kapituła Javarsovia 2010
http://javarsovia.pl

---------------------------------------------------------------------
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: How to reuse field validators?

Posted by Lukasz Lenart <lu...@googlemail.com>.
2010/4/16 Griffith, Michael * <Mi...@fda.hhs.gov>:
> Hello all,
>
> I am not clear on how to reuse a field validator that doesn't share a
> common package or action/alias.  I have package
>
> ...struts.admin/
> ...struts/application/
>
> with namespaces /admin and /application respectively.  I have a model
> object with a validator <modelClass>-validator.xml in the /application
> package that I need to reuse in the admin package.  What's the best way
> to reuse the validator without repeating it?

You can add annotation @SkipValidation


Regards
-- 
Łukasz
http://www.lenart.org.pl/
Kapituła Javarsovia 2010
http://javarsovia.pl

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