thanks a lot
I resolved it by add those getter and setters

I would consider that a hack anyway but there still needs to be a
simpler more streamlined way of achieving the same thing using the
converters.
Thanks again.

On Thu, Dec 17, 2009 at 3:32 PM, chinedu efoagui <[email protected]> wrote:
> hello @matt
>
> I carried out your instruction i still got the same error
>
> WicketMessage: Error calling method: public void
> org.apache.wicket.extensions.yui.calendar.DateTimeField.setDate(java.util.Date)
> on object: [MarkupContainer [Component id = timein]]
>
> Root cause:
>
> java.lang.IllegalArgumentException: argument type mismatch
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>     at java.lang.reflect.Method.invoke(Method.java:597)
>
> I subclassed the Datetimefield
>
> public class MwDateTimeField extends DateTimeField
> {
>
>    public MwDateTimeField(String id){
>
>        super(id);
>        //setType(Timestamp.class);
>
>    }
>
>   �...@override
>    protected DateTextField newDateTextField(String id, PropertyModel
> dateFieldModel)
>  {
>      return new DateTextField(id, dateFieldModel,new
> StyleTimeStampConverter(false));
>  }
> }
>
>
> and the StyleDateConverter
>
> public class StyleTimeStampConverter extends StyleDateConverter {
>
>
>        public StyleTimeStampConverter(boolean id){
>
>            super(id);
>
>
>        }
>
>   �...@override
>    public Timestamp convertToObject(String value, Locale locale) {
>        Date zatime=super.convertToObject(value, locale);
>
>        java.sql.Timestamp timeStampDate = new
> Timestamp(zatime.getTime());
>        return timeStampDate;
>    }
>
>
> what seems to be the problem.
>
>
>
> On Thu, Dec 17, 2009 at 2:50 PM, Matthias Keller
> <[email protected]> wrote:
>> DateTimeField internally uses a DateTextField which is a normal TextField
>> initialized as type java.util.Date
>>
>> You could create a class:
>>
>> public class TimestampField extends DateTimeField {
>>   protected DateTextField newDateTextField(String id, PropertyModel
>> dateFieldModel)
>>   {
>>       return new DateTextField(id, dateFieldModel, new
>> StyleTimestampConverter(false));
>>   }
>> }
>>
>> This allows you to create your own converter which results in a Timestamp
>> object.
>> you could for example just extend StyleDateConverter to take advantage of
>> its implementation and in your override of convertToObject() you could
>> convert the super.convertToObject() Date to Timestamp
>>
>> Matt
>>
>> chinedu efoagui wrote:
>>>
>>> Hello,
>>> I am very new to Wicket
>>> I am building an application that requires a Datetimefield
>>>
>>> The field in my database 'timein' is datetime.
>>>
>>> The pojo object accepts a java.sql.Timestamp
>>>  /**
>>>    * Returns the value of the <code>timein</code> property.
>>>    *
>>>    */
>>>   @Column(name = "timein"  )
>>>   public java.sql.Timestamp getTimein() {
>>>      return timein;
>>>   }
>>>
>>>   /**
>>>    * Sets the value of the <code>timein</code> property.
>>>    *
>>>    * @param timein the value for the <code>timein</code> property
>>>    */
>>>   public void setTimein(java.sql.Timestamp timein) {
>>>      this.timein = timein;
>>>   }
>>> but the DateTimefield uses java.util.get
>>>
>>> when i save the form to the database i get this error below
>>>
>>> org.apache.wicket.WicketRuntimeException: Error calling method: public
>>> void
>>> org.apache.wicket.extensions.yui.calendar.DateTimeField.setDate(java.util.Date)
>>> on object: [MarkupContainer [Component id = timein]]
>>>        at
>>> org.apache.wicket.util.lang.PropertyResolver$MethodGetAndSet.setValue(PropertyResolver.java:1133)
>>>        at
>>> org.apache.wicket.util.lang.PropertyResolver$ObjectAndGetSetter.setValue(PropertyResolver.java:588)
>>>        at
>>> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.java:136)
>>>        at
>>> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractPropertyModel.java:169)
>>>        at
>>> org.apache.wicket.Component.setDefaultModelObject(Component.java:3052)
>>>        at
>>> org.apache.wicket.markup.html.form.FormComponent.updateModel(FormComponent.java:1168)
>>>        at
>>> org.apache.wicket.markup.html.form.Form$FormModelUpdateVisitor.component(Form.java:225)
>>>        at
>>> org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:514)
>>>        at
>>> org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:493)
>>>        at
>>> org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:493)
>>> Caused by: org.apache.wicket.WicketRuntimeException: Error calling
>>> method: public void
>>>
>>> com.mw.hr.entity.personnelrecordsattendance.PersonnelrecordsAttendance.setTimein(java.sql.Timestamp)
>>> on object:
>>> com.mw.hr.entity.personnelrecordsattendance.personnelrecordsattenda...@1f0c408
>>>        at
>>> org.apache.wicket.util.lang.PropertyResolver$MethodGetAndSet.setValue(PropertyResolver.java:1138)
>>>        at
>>> org.apache.wicket.util.lang.PropertyResolver$ObjectAndGetSetter.setValue(PropertyResolver.java:588)
>>>        at
>>> org.apache.wicket.util.lang.PropertyResolver.setValue(PropertyResolver.java:136)
>>>        at
>>> org.apache.wicket.model.AbstractPropertyModel.setObject(AbstractPropertyModel.java:169)
>>>        at
>>> org.apache.wicket.Component.setDefaultModelObject(Component.java:3052)
>>>        at
>>> org.apache.wicket.extensions.yui.calendar.DateTimeField.setDate(DateTimeField.java:239)
>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>        at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>> Caused by: java.lang.IllegalArgumentException: argument type mismatch
>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>        at
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>        at
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>        at
>>> org.apache.wicket.util.lang.PropertyResolver$MethodGetAndSet.setValue(PropertyResolver.java:1129)
>>>        ... 51 more
>>>
>>> please can i get an idea or sample code to convert the input from the
>>> datetimefiled to java.sql.timestamp??
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>
>>
>> --
>> [email protected]  +41 44 268 83 98
>> Ergon Informatik AG, Kleinstrasse 15, CH-8008 Zürich
>> http://www.ergon.ch
>> ______________________________________________________________
>> e r g o n    smart people - smart software
>>
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to