You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by james o'brien <jo...@spinnphr.com> on 2009/05/15 01:26:03 UTC

DateTextField Runtime Exception on loading textfield that doesn't match format

I have the following:

DateTextField when = new DateTextField("when", newPropertyModel(bloodPressure,
"when"), "M/d/yyyy");

when.setOutputMarkupId(true);

when.add(new DatePicker());


When the form loads with pre-existing date of this format: "5/1/09", I get
the following error:


java.lang.IllegalArgumentException: Cannot format given Object as a Date
     at java.text.DateFormat.format(DateFormat.java:279)
     at java.text.Format.format(Format.java:133)
     at
org.apache.wicket.util.convert.converters.DateConverter.convertToString(DateConverter.java:57)
     at
org.apache.wicket.Component.getModelObjectAsString(Component.java:1605)
     at
org.apache.wicket.Component.getModelObjectAsString(Component.java:1580)


TextField doesn't puke but I have been unable to set the date format for
DatePicker without using DateTextField.


Any suggestions?


Thanks,

--jim

Re: DateTextField Runtime Exception on loading textfield that doesn't match format

Posted by jobiwankanobi <jo...@spinnphr.com>.
Never mind - I figured it out. DateTextField takes a Date not a String.
--jim


jobiwankanobi wrote:
> 
> Is there a way to make it more lenient?  I have data coming in from
> different sources - I want the form to load, give them a chance to change
> the format.
> --jim
> 
> 
> igor.vaynberg wrote:
>> 
>> your format should match what you have in your model. otherwise you
>> will get the same error when you try to stick the submitted value back
>> into your model - but the error will be on the model site.
>> 
>> -igor
>> 
>> On Thu, May 14, 2009 at 4:26 PM, james o'brien <jo...@spinnphr.com>
>> wrote:
>>> I have the following:
>>>
>>> DateTextField when = new DateTextField("when",
>>> newPropertyModel(bloodPressure,
>>> "when"), "M/d/yyyy");
>>>
>>> when.setOutputMarkupId(true);
>>>
>>> when.add(new DatePicker());
>>>
>>>
>>> When the form loads with pre-existing date of this format: "5/1/09", I
>>> get
>>> the following error:
>>>
>>>
>>> java.lang.IllegalArgumentException: Cannot format given Object as a Date
>>>     at java.text.DateFormat.format(DateFormat.java:279)
>>>     at java.text.Format.format(Format.java:133)
>>>     at
>>> org.apache.wicket.util.convert.converters.DateConverter.convertToString(DateConverter.java:57)
>>>     at
>>> org.apache.wicket.Component.getModelObjectAsString(Component.java:1605)
>>>     at
>>> org.apache.wicket.Component.getModelObjectAsString(Component.java:1580)
>>>
>>>
>>> TextField doesn't puke but I have been unable to set the date format for
>>> DatePicker without using DateTextField.
>>>
>>>
>>> Any suggestions?
>>>
>>>
>>> Thanks,
>>>
>>> --jim
>>>
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/DateTextField-Runtime-Exception-on-loading-textfield-that-doesn%27t--match-format-tp23550902p23553168.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


Re: DateTextField Runtime Exception on loading textfield that doesn't match format

Posted by jobiwankanobi <jo...@spinnphr.com>.
Is there a way to make it more lenient?  I have data coming in from different
sources - I want the form to load, give them a chance to change the format.
--jim


igor.vaynberg wrote:
> 
> your format should match what you have in your model. otherwise you
> will get the same error when you try to stick the submitted value back
> into your model - but the error will be on the model site.
> 
> -igor
> 
> On Thu, May 14, 2009 at 4:26 PM, james o'brien <jo...@spinnphr.com>
> wrote:
>> I have the following:
>>
>> DateTextField when = new DateTextField("when",
>> newPropertyModel(bloodPressure,
>> "when"), "M/d/yyyy");
>>
>> when.setOutputMarkupId(true);
>>
>> when.add(new DatePicker());
>>
>>
>> When the form loads with pre-existing date of this format: "5/1/09", I
>> get
>> the following error:
>>
>>
>> java.lang.IllegalArgumentException: Cannot format given Object as a Date
>>     at java.text.DateFormat.format(DateFormat.java:279)
>>     at java.text.Format.format(Format.java:133)
>>     at
>> org.apache.wicket.util.convert.converters.DateConverter.convertToString(DateConverter.java:57)
>>     at
>> org.apache.wicket.Component.getModelObjectAsString(Component.java:1605)
>>     at
>> org.apache.wicket.Component.getModelObjectAsString(Component.java:1580)
>>
>>
>> TextField doesn't puke but I have been unable to set the date format for
>> DatePicker without using DateTextField.
>>
>>
>> Any suggestions?
>>
>>
>> Thanks,
>>
>> --jim
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/DateTextField-Runtime-Exception-on-loading-textfield-that-doesn%27t--match-format-tp23550902p23552883.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


Re: DateTextField Runtime Exception on loading textfield that doesn't match format

Posted by Igor Vaynberg <ig...@gmail.com>.
your format should match what you have in your model. otherwise you
will get the same error when you try to stick the submitted value back
into your model - but the error will be on the model site.

-igor

On Thu, May 14, 2009 at 4:26 PM, james o'brien <jo...@spinnphr.com> wrote:
> I have the following:
>
> DateTextField when = new DateTextField("when", newPropertyModel(bloodPressure,
> "when"), "M/d/yyyy");
>
> when.setOutputMarkupId(true);
>
> when.add(new DatePicker());
>
>
> When the form loads with pre-existing date of this format: "5/1/09", I get
> the following error:
>
>
> java.lang.IllegalArgumentException: Cannot format given Object as a Date
>     at java.text.DateFormat.format(DateFormat.java:279)
>     at java.text.Format.format(Format.java:133)
>     at
> org.apache.wicket.util.convert.converters.DateConverter.convertToString(DateConverter.java:57)
>     at
> org.apache.wicket.Component.getModelObjectAsString(Component.java:1605)
>     at
> org.apache.wicket.Component.getModelObjectAsString(Component.java:1580)
>
>
> TextField doesn't puke but I have been unable to set the date format for
> DatePicker without using DateTextField.
>
>
> Any suggestions?
>
>
> Thanks,
>
> --jim
>

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