RE: Validator with DispatchAction...help!...newbie
There is an interesting article talking about validation in DispatchAction. That may not be what you are looking for but I would like to know if the method suggestted by the author is a good choice or not: http://www.reumann.net/struts/articles/request_lists.jsp Another common practice is to have a isMutable() method in ActionForm. However, it relies on the Actions to play around the 'mutable' property carefully. And is something goes wrong and the property is set/reset properly, then things may go wild. Any comments ? lixin --- Robert Taylor <[EMAIL PROTECTED]> wrote: > ValidatorForm, ValidatorActionForm, > DynaValidatorForm, and DynaValidatorActionForm allow > you to leverage the validation framework in Struts. > > How you use DispatchAction determines what you need > to do to make it > work with the validation framework. > > For example there are two basic approaches: > > 1. Differentiate different validation routines based > on form name. >Using DispatchAction you could use the same form > and identify it >with different names in the struts-config.xml > file. You can then >ensure that each action mapping using the > DispatchAction used the >appropriate form name to invoke the appropriate > validation rules >in validation.xml. > > > 2. Differentiate different validation routines based > on action mapping. >Using DispatchAction you could use the same form > with the same >identity. You can then use different action > mappings which all map >to the same DispatchAction using the same form. > Each unique action >mapping would then invoke the appropriate > validation rules in >validation.xml. > > > > There are other variations of DispatchAction such as > MappedDispatchAction > and LookupDispatchAction. Each of these might be > leveraged differently > to work with the validation framework. I've yet to > use them, so I can't > offer any advice; however, recently, there have been > some healthy threads > on both. Just don't ask Rick about > LookupDispatchAction and you'll be okay :) > > > Now, it gets kind of tricky when you want to use > DispatchAction (or some variant > there of) to perform different validation routines > using the same form name and > the same action mapping. This is typical when you > have a single form with multiple buttons, where each > button invokes a different > operation on the DispatchAction and > you want to use different validation routines for > each operation. > > Since validation routines basically key off of the > name attribute of the form > element in validation.xml, you can modify/override > the getValidationKey() in > ValidatorForm or ValidatorActionForm to > return a name including the invoked operation. There > are probably other ways > to do this and most likely more elegant. I think you > can also use the form name > in conjunction with the page attribute as the > validation key but I haven't done this > yet. > > > Digging around the source code always helps me to > understand how things work. > > > > robert > > > -Original Message- > > From: O. Oke [mailto:[EMAIL PROTECTED] > > Sent: Tuesday, September 14, 2004 8:04 PM > > To: Struts Users Mailing List > > Subject: Validator with > DispatchAction...help!...newbie > > > > > > --- Matt Bathje <[EMAIL PROTECTED]> wrote: > > > O. Oke wrote: > > > > > > > Can anyone please tell me how to use the > Struts > > > > Validator with DispatchAction. > > > > > > > > This article in bugzilla does not seem to deal > > > with > > > > the issue: > > > > > > > > > > http://issues.apache.org/bugzilla/showattachment.cgi?attach_id=8633 > > > > > > > > Thank you. > > > > > > > > Ola > > > > > > > > > > > > > Ola - we more information to be able to help > you. I > > > can't even tell what > > > your problem is, or why you think that bugzilla > > > report is/isn't related > > > to it. (Also, there are hundreds of bugzilla > reports > > > that do not apply > > > to your problem...that doesn't mean they are > helpful > > > to explain what is > > > going on.) > > > > > > > > > Matt > > > > > > > > > > Matt, > > > > Please find further detail below: > > > > > > GENERAL INFORMATION > > === > > My understanding is that the Stuts validator is > not > > designed to work with classes that extend > > DispatchAction (as against Action). However, the > > information I have found on the internet appears > to > > suggest that there is a way to make them work with > > each other. This article > > > (http://issues.apache.org/bugzilla/showattachment.cgi?attach_id=8633) > > is meant to be an explanation of howto, but on > closer > > examination, it did not seem to deal with the > issue. > > > > Can you please tell me how to make them work with > each > > other? > > > > Thank you. > > > > Ola. > > > > > > > > > > > > > ___ALL-NEW > Yahoo! Messenger - all new features - even more fun! > http://uk.messenger.yah
RE: Validator with DispatchAction...help!...newbie
ValidatorForm, ValidatorActionForm, DynaValidatorForm, and DynaValidatorActionForm allow you to leverage the validation framework in Struts. How you use DispatchAction determines what you need to do to make it work with the validation framework. For example there are two basic approaches: 1. Differentiate different validation routines based on form name. Using DispatchAction you could use the same form and identify it with different names in the struts-config.xml file. You can then ensure that each action mapping using the DispatchAction used the appropriate form name to invoke the appropriate validation rules in validation.xml. 2. Differentiate different validation routines based on action mapping. Using DispatchAction you could use the same form with the same identity. You can then use different action mappings which all map to the same DispatchAction using the same form. Each unique action mapping would then invoke the appropriate validation rules in validation.xml. There are other variations of DispatchAction such as MappedDispatchAction and LookupDispatchAction. Each of these might be leveraged differently to work with the validation framework. I've yet to use them, so I can't offer any advice; however, recently, there have been some healthy threads on both. Just don't ask Rick about LookupDispatchAction and you'll be okay :) Now, it gets kind of tricky when you want to use DispatchAction (or some variant there of) to perform different validation routines using the same form name and the same action mapping. This is typical when you have a single form with multiple buttons, where each button invokes a different operation on the DispatchAction and you want to use different validation routines for each operation. Since validation routines basically key off of the name attribute of the form element in validation.xml, you can modify/override the getValidationKey() in ValidatorForm or ValidatorActionForm to return a name including the invoked operation. There are probably other ways to do this and most likely more elegant. I think you can also use the form name in conjunction with the page attribute as the validation key but I haven't done this yet. Digging around the source code always helps me to understand how things work. robert > -Original Message- > From: O. Oke [mailto:[EMAIL PROTECTED] > Sent: Tuesday, September 14, 2004 8:04 PM > To: Struts Users Mailing List > Subject: Validator with DispatchAction...help!...newbie > > > --- Matt Bathje <[EMAIL PROTECTED]> wrote: > > O. Oke wrote: > > > > > Can anyone please tell me how to use the Struts > > > Validator with DispatchAction. > > > > > > This article in bugzilla does not seem to deal > > with > > > the issue: > > > > > > http://issues.apache.org/bugzilla/showattachment.cgi?attach_id=8633 > > > > > > Thank you. > > > > > > Ola > > > > > > > > > Ola - we more information to be able to help you. I > > can't even tell what > > your problem is, or why you think that bugzilla > > report is/isn't related > > to it. (Also, there are hundreds of bugzilla reports > > that do not apply > > to your problem...that doesn't mean they are helpful > > to explain what is > > going on.) > > > > > > Matt > > > > > > Matt, > > Please find further detail below: > > > GENERAL INFORMATION > === > My understanding is that the Stuts validator is not > designed to work with classes that extend > DispatchAction (as against Action). However, the > information I have found on the internet appears to > suggest that there is a way to make them work with > each other. This article > (http://issues.apache.org/bugzilla/showattachment.cgi?attach_id=8633) > is meant to be an explanation of howto, but on closer > examination, it did not seem to deal with the issue. > > Can you please tell me how to make them work with each > other? > > Thank you. > > Ola. > > > > > > ___ALL-NEW Yahoo! Messenger > - all new features - even more fun! http://uk.messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Validator with DispatchAction...help!...newbie
O. Oke wrote: Can anyone please tell me how to use the Struts Validator with DispatchAction. This article in bugzilla does not seem to deal with the issue: http://issues.apache.org/bugzilla/showattachment.cgi?attach_id=8633 Thank you. Ola Ola - we more information to be able to help you. I can't even tell what your problem is, or why you think that bugzilla report is/isn't related to it. (Also, there are hundreds of bugzilla reports that do not apply to your problem...that doesn't mean they are helpful to explain what is going on.) Matt - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]