Chris,

I'm really confused by this. I'm the creator of the Validator XDoclet stuff and here is an example from my project:

public class ContactInfoForm extends BaseForm {
    private AddressForm homeAddress;
    private AddressForm workAddress;

    public AddressForm getHomeAddress() {
        return homeAddress;
    }

    /**
     * @struts.validator
     */
    public void setHomeAddress(AddressForm homeAddress) {
        this.homeAddress = homeAddress;
    }

    public AddressForm getWorkAddress() {
        return workAddress;
    }

    /**
     * @struts.validator
     */
    public void setWorkAddress(AddressForm workAddress) {
        this.workAddress = workAddress;
    }
}

Notice that there are some dummy @struts.validator tags there. This is an issue that needs addressing to really make this good, but to make it work currently it has to be tagged this way. Now AddressForm looks like this:

public class AddressForm {

    private String addressLine1;
    private String addressLine2;
    private String addressLine3;
    private String city;
    private String stateCode;
    private Integer countryId;
    private String email;
    private String province;
    private String postalCode;
    private String phone;
    private String fax;

// most getters/setters omitted here

    public String getEmail() {
        return email;
    }

    /**
     * @struts.validator type="email"
     */
    public void setEmail(String email) {
        this.email = email;
    }
}

And validation.xml gets generated just fine with workAddress.email and homeAddress.email using the "email" validator.

How does this jive with what you are having issues with?

Erik


On Thursday, March 20, 2003, at 03:34 PM, Chris Butler wrote:
Issue: Validating objects that are "non-supported" types in a form with
methods that should be supported because they *do* return supported
types.


NOTE: This seems like it would come up often with ValueObjects in forms.

Struts has a validator example in which a cityStateZip object exists
within a form.  It is desirable to be able to auto-generate its
validator.xml by using XDoclet.  However, XDoclet (in
StrutsValidatorTagsHandler.java) currently will bypass any methods that
do not return base types.

Currently I do not believe I can generate the following (clip from the
Struts validation example, validation.xml):

        <field property="cityStateZip.stateProv"
                   depends="required,mask">
                     <arg0
key="registrationForm.stateprov.displayname"/>
                     <var>
                       <var-name>mask</var-name>
                       <var-value>^[a-zA-Z]*$</var-value>
                     </var>
      </field>

FROM STRUTS VALIDATOR EXAMPLE: RegistrationForm.java

    public CityStateZip getCityStateZip() {
       return csz;      
    }

    public void setCityStateZip(CityStateZip csz) {
        this.csz = csz;
    }

So - my solution was to change the XDoclet template (validation_xml.xdt)
to do the following using a new attribute of tag @struts:validator
fieldname="<somename>". This was accomplished by the below in the
template:


<XDtMethod:ifHasMethodTag tagName="struts:validator"
paramName="fieldname">
  <field property="<XDtMethod:methodTagValue tagName="struts:validator"
paramName="fieldname"/>"
</XDtMethod:ifHasMethodTag>
<XDtMethod:ifDoesntHaveMethodTag tagName="struts:validator"
paramName="fieldname">
  <field property="<XDtValidator:fieldName/>"
</XDtMethod:ifDoesntHaveMethodTag>

However, due to bypassing the non-supported type in the
StrutsValidatorTagsHandler, I'm basically forced to create a faux
mutator method (String setHackySolutionForMyComplexObject()) and place
the tag there in order to get it to work properly...  since String is a
handled type.  This ends up being a very hacky solution in my book.

Does anyone have any thoughts on the right way to do this?  Ultimately,
I know that Struts Validator should handle validating an object as long
as the target setter method to validate will use those base types...
particularly since the core Validator example uses such an object.

Or, if I'm way off-base and there's an easy solution, let me know that
too. :-)

Chris



-------------------------------------------------------
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




-------------------------------------------------------
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

Reply via email to