Hi,

I encountered several problems using validators on a datetimepicker field
form.

Here is the html code :  <sx:datetimepicker key="startDate" id="startDate"
toggleType="explode" toggleDuration="500" required="true"
displayFormat="dd/MM/yyyy"/>

In my action there are the startDate field :

private Date startDate;
public Date getStartDate() { return startDate; }
public void setStartDate(Date startDate) { this.startDate = startDate; }

and the validation file part :

    <field name="startDate">
        <field-validator type="required">
            <message key="required"/>
        </field-validator> 
            <field-validator type="date" short-circuit="true">
            <message key="invalid.fieldvalue.startDate"/>
        </field-validator>       
        <field-validator type="afterequaldate">
            <message key="date.error.afterEqualToday"/>
        </field-validator>
    </field>

It seems that the conversionError interceptor configured in the struts/xml
file catches an invalid fieldvalue error when users type non date type text.
I had to redefine this message in the date validator in order to have a
customed message. So the conversionError occurs and then give hand to
validation interceptor.

In this case the message "invalid.field.value.startDate" is triggered but
also a "required" message type. I don't understand why I have both messages.
It's as if when the conversionError interceptor catches the startDate
parameter, it searches in the validator fields if he should try some
conversions, like the Date type and if it fails it throws an
invalid.fieldvalue error, erase the value of the parameter and give it after
on the validation interceptor.

I don't understand this behaviour as I don't know how i could fix the
conversion errors before. It seems conversion try to convert Dates from
server local with browser local. I think it is rather stupid but to deal
with that, could I force the conversion interceptor to accept conversions
from the datetimepicker field into a Date ?

Thanx for your concern,

Alan
-- 
View this message in context: 
http://www.nabble.com/Validator-with-datetimepicker-tp20770339p20770339.html
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to