0

So I am trying to replace what was a text field to get time from my users with a TimeField (of the type mentioned in the title).

I am running into all kinds of problems. Namely, that the TimeField, absolutely must be Timefield type, and doesn't easily convert to a java.util.Date or even a string??? Very frustatring. At any, case, I keep getting

Caused by: java.lang.ClassCastException: com.usaa.infrastructure.calculator.admin.panels.SloDefinitionEditPanel$21 incompatible with java.util.Date
at org.apache.wicket.extensions.yui.calendar.DateTimeField.onBeforeRender(DateTimeField.java:429)

So basically, this is what I have in my panel:

private TimeField                            dueTimestamp           = null;

I set up the standartd Timefield class as well...

randoTimestamp = new TimeField("randoTimestamp", new PropertyModel<Date>(this, "randoTimestamp"))
    {   
        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled()
        {
            return readOnly ? false : true;
        }

        @Override
        protected boolean use12HourFormat(){
            return false;
        }


    };

Is there an override or something I can use to help mitigate this java.util.date issue? Almost forgot to mention, I set my DAO object as a java.util.Date object. Should I set it equal to something else? String, ect???

public class wackyVO implements Serializable {

private static final long serialVersionUID = -2592713376857273204L;

...  
private Date randoTimeStamp;  //<-- This variable
...
}
SoftwareSavant
  • 9,467
  • 27
  • 121
  • 195
  • Isn't your PropertyModel simply pointing to the wrong field? You specified "dueTimestamp" as field name to get the Date from, but this is actually your TimeField, hence the ClassCastException. You probably want to point it to "randoTimeStamp": `new PropertyModel(this, "randoTimeStamp"))` – Tekki May 17 '16 at 21:57
  • Good Eye, But, that was not the problem, I think the wicket compiler would have spotted that one. That was a bad edit job on my part. – SoftwareSavant May 23 '16 at 13:37

1 Answers1

0

The problem is that you put your Panel as object in the Model you are passing to the TimeField.

use this if your default modelObject is set.

randoTimestamp = new TimeField("randoTimestamp", new PropertyModel<Date>(this.getDefaultModelObject(), "randoTimestamp"))

Otherwise use

randoTimestamp = new TimeField("randoTimestamp", new PropertyModel<Date>(this.getYourModelObject(), "randoTimestamp"))
GeppyZ
  • 111
  • 4