Buy me a coffee :)

Wicket - jQuery UI

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


  • item #1
  • item #2
  • item #3
  • item #4
  • item #5
  • item #6

Components / Samples


The supplied list should be modifiable for the new order to be reflected on 'update' event. That means, the use of Arrays#asList() or Collections#unmodifiableList() should be avoided.
If you don't want the new order is reflected to the model object, remove the call to super.onUpdate(...)




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

import java.util.List;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.panel.EmptyPanel;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.util.lang.Generics;

import com.googlecode.wicket.jquery.core.resource.StyleSheetPackageHeaderItem;
import com.googlecode.wicket.jquery.ui.JQueryIcon;
import com.googlecode.wicket.jquery.ui.interaction.sortable.Sortable;
import com.googlecode.wicket.jquery.ui.interaction.sortable.Sortable.HashListView;
import com.googlecode.wicket.jquery.ui.panel.JQueryFeedbackPanel;

public class DefaultSortablePage extends AbstractSortablePage
	private static final long serialVersionUID = 1L;

	public DefaultSortablePage()
		final List<String> list = newList("item #1", "item #2", "item #3", "item #4", "item #5", "item #6");

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

		// Sortable //
		final Sortable<String> sortable = new Sortable<String>("sortable", list) {

			private static final long serialVersionUID = 1L;

			protected HashListView<String> newListView(IModel<List<String>> model)
				return DefaultSortablePage.newListView("items", model);

			public void onUpdate(AjaxRequestTarget target, String item, int index)
				// Will update the model object with the new order
				// Remove the call to super if you do not want your model to be updated (or you use a LDM)
				super.onUpdate(target, item, index);"'%s' has moved to position %d", item, index + 1));"The list order is now: " + this.getModelObject());



	// Methods //

	public void renderHead(IHeaderResponse response)

		response.render(new StyleSheetPackageHeaderItem(DefaultSortablePage.class));

	// Factories //

	protected static HashListView<String> newListView(String id, IModel<List<String>> model)
		return new HashListView<String>(id, model) {

			private static final long serialVersionUID = 1L;

			protected void populateItem(ListItem<String> item)
				item.add(new EmptyPanel("icon").add(AttributeModifier.append("class", "ui-icon " + JQueryIcon.ARROW_2_N_S)));
				item.add(new Label("item", item.getModelObject()));
				item.add(AttributeModifier.append("class", "ui-state-default"));

	 * Gets a new <i>modifiable</i> list
	private static List<String> newList(String... items)
		List<String> list = Generics.newArrayList();

		for (String item : items)

		return list;
<!DOCTYPE html>
<html xmlns:wicket="">
	<title>Wicket jQuery UI: sortable</title>
		<ul wicket:id="sortable" class="sortable">
			<li wicket:id="items">
				<span wicket:id="icon">[icon]</span>
				<span wicket:id="item" class="item">[label]</span>
		<div wicket:id="feedback" style="width: 60%;"></div>
.sortable {
	list-style-type: none;
	margin: 0;
	padding: 0;
	width: 60%;

.sortable li {
	margin: 0.3em;
	padding: 0.3em;
	font-size: 1.1em;
	background-color: #fff;