You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Federico Fanton <ff...@ibc.it> on 2007/08/03 17:14:23 UTC
DateField with a Calendar
Hi everyone!
I just migrated to 1.3.0-beta2 from 1.2.6, and I'm trying to replace DatePicker's with DateField's, but I'm having a problem because the "backbean" of the CompoundPropertyModel of the containing form uses a Calendar field, not a Date one, so I'm receiving a conversion exception..
I have a custom Converter in place that would handle the conversion, but it doesn't get called, because PropertyResolverConverter calls it only when there's a String involved in the conversion, while the DateField would need a "Date to Calendar" conversion..
I thought of subclassing DateField and handling the conversion overriding setDate, but the "date" field inside DateField is private.. Any hint on what I could try?
Many thanks for your time!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField with a Calendar
Posted by Gerolf Seitz <ge...@gmail.com>.
a quick workaround, although maybe not a proper solution would be the
following:
... // somewhere in constructor
form.add(new DateField("myId", new PropertyModel(this, "calendarDate")));
...
}
private void setCalendarDate(Date date) {
myCalendar.setTime(date);
}
private Date getCalendarDate() {
return myCalendar.getTime();
}
On 8/3/07, Federico Fanton <ff...@ibc.it> wrote:
>
> Hi everyone!
> I just migrated to 1.3.0-beta2 from 1.2.6, and I'm trying to replace
> DatePicker's with DateField's, but I'm having a problem because the
> "backbean" of the CompoundPropertyModel of the containing form uses a
> Calendar field, not a Date one, so I'm receiving a conversion exception..
> I have a custom Converter in place that would handle the conversion, but
> it doesn't get called, because PropertyResolverConverter calls it only when
> there's a String involved in the conversion, while the DateField would need
> a "Date to Calendar" conversion..
> I thought of subclassing DateField and handling the conversion overriding
> setDate, but the "date" field inside DateField is private.. Any hint on what
> I could try?
> Many thanks for your time!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: DateValidator message data customisation
Posted by Paolo Di Tommaso <pa...@gmail.com>.
I've found a workaround to this problem, using as "min" and "max" date
values not a java.util.Date instance but a MyDate class that overrides the
toString() with my custom date format.
- Paolo
On 8/3/07, Mael Sicsic <ms...@tentelemed.com> wrote:
>
> Hi,
>
> I have 2 problems with DateValidator' error messages.
> I understand how to configure the text message for validation error (eg :
> "xxx must be between {min} and {max}"), but my problems are with the value
> of dates "minimum" and "maximum", that are allways displayed in the EN
> locale style and are too verbose.
> For example it displays "must be between Sun Dec 31 18:59:48 CET 1979 and
> ...", and I would like to display "must be between 31/12/1979 and ..."
>
> Is it possible to change the format of values in the IValidators messages
> ?
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
DateValidator message data customisation
Posted by Mael Sicsic <ms...@tentelemed.com>.
Hi,
I have 2 problems with DateValidator' error messages.
I understand how to configure the text message for validation error (eg :
"xxx must be between {min} and {max}"), but my problems are with the value
of dates "minimum" and "maximum", that are allways displayed in the EN
locale style and are too verbose.
For example it displays "must be between Sun Dec 31 18:59:48 CET 1979 and
...", and I would like to display "must be between 31/12/1979 and ..."
Is it possible to change the format of values in the IValidators messages ?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField with a Calendar
Posted by Federico Fanton <ff...@ibc.it>.
On Fri, 3 Aug 2007 09:22:01 -0700
"Igor Vaynberg" <ig...@gmail.com> wrote:
> you cant use the compound property model then, you have to write your own
> model that will do the conversion
I ended up with a custom implementation of the AttachedCompoundPropertyModel.. Many thanks to all who answered :)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: DateField with a Calendar
Posted by Igor Vaynberg <ig...@gmail.com>.
you cant use the compound property model then, you have to write your own
model that will do the conversion
-igor
On 8/3/07, Federico Fanton <ff...@ibc.it> wrote:
>
> Hi everyone!
> I just migrated to 1.3.0-beta2 from 1.2.6, and I'm trying to replace
> DatePicker's with DateField's, but I'm having a problem because the
> "backbean" of the CompoundPropertyModel of the containing form uses a
> Calendar field, not a Date one, so I'm receiving a conversion exception..
> I have a custom Converter in place that would handle the conversion, but
> it doesn't get called, because PropertyResolverConverter calls it only when
> there's a String involved in the conversion, while the DateField would need
> a "Date to Calendar" conversion..
> I thought of subclassing DateField and handling the conversion overriding
> setDate, but the "date" field inside DateField is private.. Any hint on what
> I could try?
> Many thanks for your time!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>