Hi
Essentially I've made my own datepicker and timepicker using some jquery
components. I am having my two components editing the same model (one edits
time and the other date). Both components extending datetextfield
Problem are if I change time then month/day are reset. Im thinking that it
has something todo with hourdatetextfield are the last component added. I've
tried various things also editing the raw model object. Nothing works..
public class HourDateTextField extends DateTextField {
public HourDateTextField(String id, IModel<Date> model,
DateConverter converter) {
super(id, model, converter);
add(new TimePickerBehavior());
}
@Override
protected void convertInput() {
MutableDateTime dateOld = new MutableDateTime(getModelObject());
super.convertInput();
Date dateNew = this.getConvertedInput();
dateOld.setHourOfDay(dateNew.getHours());
dateOld.setMinuteOfHour(dateNew.getMinutes());
setModelObject(dateOld.toDate());
}
}
public class MonthDayDateTextField extends DateTextField {
public MonthDayDateTextField(String id, IModel<Date> model,
DateConverter converter) {
super(id, model, converter);
add(new DatePickerBehavior());
}
@Override
protected void convertInput() {
MutableDateTime dateOld = new MutableDateTime(getModelObject());
super.convertInput();
Date dateNew = this.getConvertedInput();
dateOld.setDayOfMonth(dateNew.getDay());
dateOld.setMonthOfYear(dateNew.getMonth());
setModelObject(dateOld.toDate());
}
}