Hi all,

The problem I'd like to discuss is how Validator works with form properties. IMHO there is a contradiction (or maybe I don't know how to resolve this problem - in this case, please help me) with types of Form properties. The end result is that if I want to use the Validator, all my form properties MUST be java.lang.String, otherwise Struts (in fact BeanUtils and ConvertorUtils) throws org.apache.commons.beanutils.ConversionException. So why should specify the type of form properties if Validator so and so doesn't work with any other type than java.util.String.
To clarify the problem here is an example:
I have this form:
       <form-bean name="testValidation"
           type="org.apache.struts.validator.DynaValidatorForm">
           <form-property name="startDate" type="java.util.Date" />
           <form-property name="endDate" type="java.util.Date" />
       </form-bean>

and here is the snippet of my validation.xml file that should check that the dates entered are in some special format:
       <form name="testValidation">
           <field property="startDate"
                   depends="date">
                   <arg key="startDate"/>
               <var>
               <var-name>datePattern</var-name>
               <var-value>yyyy-MM-dd</var-value>
</var> </field>
           <field property="endDate"
                   depends="date">
                   <arg key="endDate"/>
               <var>
               <var-name>datePattern</var-name>
               <var-value>yyyy-MM-dd</var-value>
</var> </field>
       </form>

The idea behind this is that I want the parameters that are coming with the request, to be "translated" to their expected types once and only once! So if you try this, you will get org.apache.commons.beanutils.ConversionException (thrown from RequestProcessor if I remember correctly).

As soon as I set this
           <form-property name="startDate" type="java.lang.String" />
           <form-property name="endDate" type="java.util.String" />
the validator starts to work correctly.
So here I see at least 2 problems:
1. I'm forced again to parse the String properties of the form to proper java.util.Date objects (or whatever other type it has to be) 2. because of 1. , my date format string now is in 2 places instead of one place i.e. I have a support problem

So IMHO this is a "framework" inconsistency since.
Please tell me if I do something wrong or this is one of "known limitations".


Borislav

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to