Buy me a coffee :)

Wicket - jQuery UI

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

Draggable Component

Drag me around

Components / Samples


The draggable component allows to be notified when the drag starts and when the drag stops (onDragStart and onDragStop).


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

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.html.panel.FeedbackPanel;

import com.googlecode.wicket.jquery.core.resource.StyleSheetPackageHeaderItem;
import com.googlecode.wicket.jquery.core.utils.RequestCycleUtils;
import com.googlecode.wicket.jquery.ui.interaction.draggable.Draggable;
import com.googlecode.wicket.jquery.ui.panel.JQueryFeedbackPanel;

public class ComponentDraggablePage extends AbstractDraggablePage
	private static final long serialVersionUID = 1L;

	public ComponentDraggablePage()
		// FeedbackPanel //
		final FeedbackPanel feedback = new JQueryFeedbackPanel("feedback");

		// Draggable //
		this.add(new Draggable<Void>("draggable") {

			private static final long serialVersionUID = 1L;

			public boolean isStopEventEnabled()
				return true;

			public void onDragStart(AjaxRequestTarget target, int top, int left)
			{"Drag started - position: {%s, %s}", top, left));


			public void onDragStop(AjaxRequestTarget target, int top, int left)
				double offsetTop = RequestCycleUtils.getQueryParameterValue("offsetTop").toDouble(-1);
				double offsetLeft = RequestCycleUtils.getQueryParameterValue("offsetLeft").toDouble(-1);"Drag stoped - position: {%d, %d}, offset: {%.1f, %.1f}", top, left, offsetTop, offsetLeft));


	// Methods //

	public void renderHead(IHeaderResponse response)

		response.render(new StyleSheetPackageHeaderItem(ComponentDraggablePage.class));
<!DOCTYPE html>
<html xmlns:wicket="">
	<title>Wicket jQuery UI: draggable component</title>
	<div id="demo-panel">
		<div wicket:id="draggable" class="ui-widget-content">
			<p>Drag me around</p>
		<div wicket:id="feedback" style="width: 360px;"></div>
.ui-draggable {
	width: 130px;
	height: 60px;
	padding: 0.5em;
	z-index: 99;