to the heart of the issue. Currently there is no problem with the
standard String validation, but nothing will be generated for the second
validation tag... setCityStateZip() because it is not a supported type.
I believe this is a result from line 298 in
StrutsValidatorTagsHandler.java (method = getFields()).
if (supportedTypes.contains(type)) {
That check is only done after it recursively descends the beans. So it descend into CityStateZip.
/**
* @struts.action
* name="registrationForm"
* path="/register"
* scope="request"
* unknown="false"
* validate="true"
*/
public final class RegistrationForm extends ValidatorForm implements
Serializable {
You're putting action mappings on form beans? *ick* (sorry, a pet peeve of mine, but we'll gloss over this one :)...
WHAT I WOULD LIKE TO BE ABLE TO DO (or something like it):
/** * @struts.validator * fieldname="csz.city" * type="required" * msgkey="error.required" * * @struts.validator * fieldname="csz.state" * type="required" * msgkey="error.required" * * @struts.validator * fieldname="csz.zip" * type="required" * msgkey="error.required" */ public void setCityStateZip(CityStateZip csz) { this.csz = csz; }
But look at the example I provided. The way to do it (currently) is to tag the city, state, and zip setters in CityStateZip instead, not the parent (except with just the marker @struts.validator so it knows to descend into it). Its not idea, I know. But nested form beans are rarely used (in my experience) and we only use one in our entire system of 50+ forms.
But, what you are showing can be done with <strutsvalidationxml> as-is by following the pattern I described with no modifications.
Any ideas or thoughts on approach would be great. Right now I
essentially wrote a hack to the validation template for a new tag
(fieldname) and then use empty setter methods with valid supportedTypes
(in my case, String) so that the proper validation.xml is generated.
It's a hacky solution, but it's generating the proper validation.xml for
the time being.
Again, the supported types is not the issue here. It works on nested beans (recursively as deep as you like) by simply tagging the setter that sets the nested bean. Try my pattern and see if you get successful results and then work from there to make it better if need be.
Erik
-------------------------------------------------------
This SF.net email is sponsored by: Tablet PC. Does your code think in ink? You could win a Tablet PC. Get a free Tablet PC hat just for playing. What are you waiting for? http://ads.sourceforge.net/cgi-bin/redirect.pl?micr5043en
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user
