Buy me a coffee :)

Wicket - jQuery UI

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

Draggable & Droppable Behaviors

Drag everywhere here...

Drag me!

Components / Samples

Description

Since

wicket-kendo-ui-kendo-6.20.0 wicket-kendo-ui-kendo-7.0.0

Licensing

Kendo UI "Core" is Apache License 2.0 licensed, starting from version 2014.1.416.
Prior to version 2014.1.416, Kendo UI "Web" was licensed under GPLv3.

A pro version - with a commercial license - is also available, it provides additional widgets (see http://docs.telerik.com/kendo-ui/intro/supporting/list-of-widgets)
To be able to use it, you need to change the ResourceReference with kendo.all.min.js

See also

[howto]-change-resource-references

Sources

  • Java
  • HTML
  • CSS
package com.googlecode.wicket.jquery.ui.samples.kendoui.dragdrop;

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.html.WebMarkupContainer;

import com.googlecode.wicket.jquery.core.resource.StyleSheetPackageHeaderItem;
import com.googlecode.wicket.kendo.ui.console.Console;
import com.googlecode.wicket.kendo.ui.interaction.draggable.DraggableBehavior;
import com.googlecode.wicket.kendo.ui.interaction.draggable.IDraggableListener;
import com.googlecode.wicket.kendo.ui.interaction.droppable.DroppableAdaper;
import com.googlecode.wicket.kendo.ui.interaction.droppable.DroppableBehavior;
import com.googlecode.wicket.kendo.ui.interaction.droppable.IDroppableListener;

public class BehaviorDragDropPage extends AbstractDragDropPage implements IDraggableListener
{
	private static final long serialVersionUID = 1L;

	private final Console console;

	public BehaviorDragDropPage()
	{
		// console //
		this.console = new Console("console");
		this.add(this.console);

		// draggable //
		WebMarkupContainer container = new WebMarkupContainer("draggable");
		container.add(new DraggableBehavior(this));
		this.add(container);

		// droppable //
		this.add(new DroppableBehavior("#wrapper-panel-frame", this.newDroppableListener()));
	}

	// Methods //

	@Override
	public void renderHead(IHeaderResponse response)
	{
		super.renderHead(response);

		response.render(new StyleSheetPackageHeaderItem(BehaviorDragDropPage.class));
	}

	protected void info(AjaxRequestTarget target, String message)
	{
		this.console.info(target, message);
	}

	protected void info(AjaxRequestTarget target, String message, Component component)
	{
		this.console.info(target, String.format("%s - %s", message, component.getMarkupId()));
	}

	// IDraggableListener //

	@Override
	public boolean isCancelEventEnabled()
	{
		// not enabled to prevent unnecessary server round-trips.
		return false;
	}

	@Override
	public void onDragStart(AjaxRequestTarget target, int top, int left)
	{
		this.info(target, String.format("Draggable: onDragStart, position [%d, %d]", top, left));
	}

	@Override
	public void onDragStop(AjaxRequestTarget target, int top, int left)
	{
		this.info(target, String.format("Draggable: onDragStop, position [%d, %d]", top, left));
	}

	@Override
	public void onDragCancel(AjaxRequestTarget target, int top, int left)
	{
		// noop
	}

	// IDroppableListener //

	private IDroppableListener newDroppableListener()
	{
		return new DroppableAdaper() {

			private static final long serialVersionUID = 1L;

			@Override
			public void onDrop(AjaxRequestTarget target, Component component)
			{
				info(target, "Droppable: onDrop", component);
			}
		};
	}
}
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
<head>
<wicket:head>
	<title>Wicket - Kendo UI: draggable</title>
</wicket:head>
</head>
<body>
<wicket:extend>
	<div id="demo-panel">
		Drag everywhere here...<br/>
		<br/>
		<div wicket:id="draggable" class="draggable">
			<div>Drag me!</div>
		</div>
	</div>
	<br/>
	<div wicket:id="console"></div>
</wicket:extend>
</body>
</html>
#wrapper-panel-frame {
	height: 256px;
}

.draggable {
	cursor: move;
	width: 96px;
	height: 48px;
	border-radius: 1em;
	background-color: orange;
}

.draggable DIV {
	padding: 1em;
}

.console {
	height: 128px;
}

/* class of the element being dragged */
.kendoDraggable-clone {
	border: 2px solid gray;
}

/* class added on the original element */
.kendoDraggable-hide {
	display: none;
}