java - Wicket: set JodaDateTime from form -


I am using wickets and hibernation for the development of a website. I just want to save some data in a form. My object is the same:

  @ Entity @Table (name = "PRODUCT") @ Inheritance (strategy = inheritance type.Single_TableElL) @desimminator column (name = "deciminator", discriminant type = deciminator Type {type = "org" @@DiscriminatorValue (value = "product") public category product implementation serializable {@Id @GeneratedValue @Column (name = "PRODUCT_ID") private int product ID; @column (name = "START_DATE") @ .jadira.usertype.dateandtime.joda.PersistentDateTime ") Private DateTime Startups; Universal Generic date time getStartDate () {return startDate;} Public Zero SetStartdate {date.time}} This < I use it for the date fields:  
  date picture date picture = new date picture (date) date converter date converter = new patterndet converter ("dd.mm.yyyy ", Incorrect); Last DatePrintField StartDate = New DateTextFill E ( "early" date converter); startDate.add (datepicker);   

I get this exception if I submit the form:

  Final reason: the value could not be changed: 08.10.14 to type For: org.joda.time. Could not get compatible converter WicketMessage: Component Targeted on component component org.apache.wicket.markup.html.form.IFormSubmitListener component [form [component id = form] on component [form [component id = form]] threw an exception  < / Ex> 

I think because the wicket uses the setter for the startdate, but how can you edit it?

If you use CompoundPropertyModel for your form, then form The components will search for this field of the actual model object, to apply values ​​(id: should be the id of the form component should be equal to the name of the area of ​​the model and this type of field should be similar to the form component return).

But if there is no related field in the model, or we want to use the free form component, then we need to use another model for this type of component.

Your exception is the fact that after the conversion, DateTextField returns date and your model has the DateTime field.

Therefore, you have at least two ways to deal with this:

  1. Use a custom model for this field and date date time object
  2. But, I think it's better to use your own converter. You can return your DateTextField to the DateTime object for your model. Look for better information on how to get it or look at (URL TextField src) you can change your own converter on org.apache.wicket.datetime.DateConverter src can be applied.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -