datecontainer.setOutputMarkupId(true);
add(datecontainer);
final TextField<Date> datePickerInput = new TextField<Date>("datePickerInput", new Model<Date>());
DatePicker datePicker = new DatePicker(new PackageResourceReference(TestPage.class, "calendar20x22.gif")) {
private static final long serialVersionUID = 1L;
@Override
protected void onSelect(final AjaxRequestTarget target, final String pickedDate, final SpecialKeys specialKeys) {
target.appendJavaScript(
"alert('Selected Date: " + pickedDate + ", Pressed keys: " +
specialKeys.toString() + "');"
);
}
@Override
protected void onChangeMonthYear(final AjaxRequestTarget target, final String year, final String month, final SpecialKeys specialKeys) {
target.appendJavaScript(
"alert('Selected Year: " + year + ", selected month: " + month + ", Pressed keys: " +
specialKeys.toString() + "');"
);
}
}
.setWantOnSelectNotification(true)
.setWantOnChangeMonthYearNotification(true)
;
datePickerInput.add(datePicker);
datecontainer.add(datePickerInput);
add(new AjaxLink<Void>("ajaxLinkRedrawDate") {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
datePickerInput.setModelObject(new Date());
target.add(datePickerInput);
}
});
add(new AjaxLink<Void>("ajaxLinkRedrawDateContainer") {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
datePickerInput.setModelObject(new Date());
target.add(datecontainer);
}
});
//inline datePicker
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Calendar c = Calendar.getInstance();
c.setTime(new Date());
c.add(Calendar.MONTH, -5);
WebMarkupContainer inlineDatePickerContainer = new WebMarkupContainer("inlineDatePickerContainer");
DatePicker inlineDatePicker = new DatePicker(){
@Override
public void setRestoreAfterRedraw(boolean value) {
super.setRestoreAfterRedraw(true);
}