You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Eric Rotick <pc...@gmail.com> on 2008/04/02 11:56:52 UTC

Re: DateTextField and DatePicker are not using the same date pattern

Further to this I've now checked the source and the DatePicker does
correctly pick up the date format from the DateTextField or, alternatively,
an overridden getDatePattern also works.

It seems to be going wrong when the date is sent from the DatePicker back to
the DateTextField via the onchange Javascript event handler. I've not yet
figured out how this works yet.

Has anyone used the DatePicker in this way to confirm that it does or does
not work as expected?


On Fri, Mar 28, 2008 at 1:18 PM, Eric Rotick <pc...@gmail.com> wrote:

> I have a situation where the DateTextField and DatePicker are not using
> the same date pattern although I set them to the same value.
>
> If I have an existing date in the model then it is formatted correctly and
> that date is also inherited correctly when the DatePicker opens. When I then
> select a different date in the DatePicker the correct date value is returned
> to the DateTextField but the format it wrong. Then if I submit the form I
> get an error on the DateTextField.
>
> For example, if I select a date of "28/Mar/2008" in the DatePicker it gets
> returned to the DateTextField as "28/3/2008".
>
> Any ideas?
>
> import org.apache.wicket.datetime.markup.html.form.DateTextField;
> import org.apache.wicket.datetime.PatternDateConverter;
> import org.apache.wicket.extensions.yui.calendar.DatePicker;
> ...
>
> public class DateField extends Panel {
>
>     public DateField(
>         String id,
>         boolean readonly,
>         IField field,
>         IModel model
>     )
>     {
>         super( id );
>
>
>         final String dateFormat = "dd/MMM/yyyy";
>         PatternDateConverter pdc = new PatternDateConverter( dateFormat,
> true );
>
>         DateTextField dtf = new DateTextField( "textValue", new
> NamedAccessorModel( model, field.getModelName( ) ), pdc );
>         add( dtf );
>
>         DatePicker dp = new DatePicker( ) {
>             protected boolean enableMonthYearSelection( ) {
>                 return true;
>             }
>             protected String getDatePattern( ) {
>                 return dateFormat;
>             }
>         };
>         dtf.add( dp );
>     }
>
> }
>
>
>

Re: DateTextField and DatePicker are not using the same date pattern

Posted by taygolf <ta...@gmail.com>.
Yes it is doing the same thing to me. The formats are off unless I use S- for
my date style which is not really what I want to use.

Have you found a fix for this?

Thanks

T

Eric Rotick wrote:
> 
> Further to this I've now checked the source and the DatePicker does
> correctly pick up the date format from the DateTextField or,
> alternatively,
> an overridden getDatePattern also works.
> 
> It seems to be going wrong when the date is sent from the DatePicker back
> to
> the DateTextField via the onchange Javascript event handler. I've not yet
> figured out how this works yet.
> 
> Has anyone used the DatePicker in this way to confirm that it does or does
> not work as expected?
> 
> 
> On Fri, Mar 28, 2008 at 1:18 PM, Eric Rotick <pc...@gmail.com> wrote:
> 
>> I have a situation where the DateTextField and DatePicker are not using
>> the same date pattern although I set them to the same value.
>>
>> If I have an existing date in the model then it is formatted correctly
>> and
>> that date is also inherited correctly when the DatePicker opens. When I
>> then
>> select a different date in the DatePicker the correct date value is
>> returned
>> to the DateTextField but the format it wrong. Then if I submit the form I
>> get an error on the DateTextField.
>>
>> For example, if I select a date of "28/Mar/2008" in the DatePicker it
>> gets
>> returned to the DateTextField as "28/3/2008".
>>
>> Any ideas?
>>
>> import org.apache.wicket.datetime.markup.html.form.DateTextField;
>> import org.apache.wicket.datetime.PatternDateConverter;
>> import org.apache.wicket.extensions.yui.calendar.DatePicker;
>> ...
>>
>> public class DateField extends Panel {
>>
>>     public DateField(
>>         String id,
>>         boolean readonly,
>>         IField field,
>>         IModel model
>>     )
>>     {
>>         super( id );
>>
>>
>>         final String dateFormat = "dd/MMM/yyyy";
>>         PatternDateConverter pdc = new PatternDateConverter( dateFormat,
>> true );
>>
>>         DateTextField dtf = new DateTextField( "textValue", new
>> NamedAccessorModel( model, field.getModelName( ) ), pdc );
>>         add( dtf );
>>
>>         DatePicker dp = new DatePicker( ) {
>>             protected boolean enableMonthYearSelection( ) {
>>                 return true;
>>             }
>>             protected String getDatePattern( ) {
>>                 return dateFormat;
>>             }
>>         };
>>         dtf.add( dp );
>>     }
>>
>> }
>>
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/DateTextField-and-DatePicker-are-not-using-the-same-date-pattern-tp16351493p18030470.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org