Hi, I've used Datepicker with play 1.2.7, but I was using twitter bootstrap for styling. I was using plugins:
Model - definition of field:
@Type(type="org.joda.time.contrib.hibernate.PersistentDateTime")
public DateTime dateFrom;
@Type(type="org.joda.time.contrib.hibernate.PersistentDateTime")
public DateTime dateTo;
javascript part:
$('.datePicker').datepicker({'weekStart': 1});
Controller part is standard controller, all data should be set automagically.
public static void doAddHoliday(@Valid Holiday holiday) {
if (validation.hasErrors()) {
params.flash();
validation.keep();
addHoliday();
} else {
holiday.save();
flash.success("holiday.add.success");
}
index();
}
but if doesn't, you can catch it separately:
Example from another controller:
public static void doNewLoan(Long id, @As("dd-MM-yyyy") DateTime dateFrom, @As("dd-MM-yyyy") DateTime dateTo,
View Part:
<div class="controls">
<input type="text" size="30" name="holiday.forDay" class="input-small datePicker" id="holiday_forDay"
value="${org.joda.time.DateMidnight.now().withDayOfWeek(org.joda.time.DateTimeConstants.SUNDAY).toString("dd-MM-yyyy")}"
data-date-format="dd-mm-yyyy" >
</div>
value is set to next sunday for default.
Catch this!!!!!:
date format at java and javascript aren't the same if you want to format date as day-month-year in the java part You use "dd-MM-yyyy" but in the javascript "dd-mm-yyyy"! Small doubleM in java will be treated as minutes not months.
Hope this help