Buy me a coffee :)

Wicket - jQuery UI

jQuery UI integration in Wicket 6.x, Wicket 7.x , Wicket 8.x & Wicket 9.x

Ajax DatePicker



Components / Samples

Description

AjaxDatePicker is close to DatePicker except that it performs an ajax post when the value changes.
You may override #onValueChanged() as follow:

form.add(new AjaxDatePicker("datepicker", model) {

	@Override
	protected void onValueChanged(AjaxRequestTarget target)
	{
		Date date = this.getModelObject();
		//TODO: do something with the date...
	}
});

Sources

package com.googlecode.wicket.jquery.ui.samples.jqueryui.datepicker;

import java.util.Date;

import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.Model;

import com.googlecode.wicket.jquery.ui.form.datepicker.AjaxDatePicker;
import com.googlecode.wicket.jquery.ui.panel.JQueryFeedbackPanel;

public class AjaxDatePickerPage extends AbstractDatePickerPage
{
	private static final long serialVersionUID = 1L;

	public AjaxDatePickerPage()
	{
		this.initialize();
	}

	private void initialize()
	{
		final Form<Date> form = new Form<Date>("form");
		this.add(form);

		// FeedbackPanel //
		final FeedbackPanel feedback = new JQueryFeedbackPanel("feedback");
		form.add(feedback.setOutputMarkupId(true));

		// Date Picker //
		form.add(new AjaxDatePicker("datepicker", new Model<Date>()) {

			private static final long serialVersionUID = 1L;

			@Override
			public void onValueChanged(IPartialPageRequestHandler handler)
			{
				info("Selected date: " + this.getModelObject());
				handler.add(feedback);
			}
		});
	}
}
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head>
<wicket:head>
	<title>Wicket jQuery UI: ajax date-picker</title>
</wicket:head>
</head>
<body>
<wicket:extend>
	<div id="demo-panel">
		<form wicket:id="form">
			<input wicket:id="datepicker" type="text" /><br/>
			<br/>
			<div wicket:id="feedback" style="width: 360px;"></div>
		</form>
	</div>
</wicket:extend>
</body>
</html>