final Label serverState = new Label("serverState", new PropertyModel(this, "choices"));
serverState.setOutputMarkupId(true);
add(serverState);
SortableList container = new SortableList("sortableList")
{
@Override
protected void onDrop(AjaxRequestTarget target, Component component, int index)
{
Component label = ((MarkupContainer) component).get("label");
String value = label.getDefaultModelObjectAsString();
choices.remove(value);
choices.add(index, value);
target.addComponent(serverState);
}
};
add(container);
RepeatingView view = new RepeatingView("sortableItem");
List<String> list = choices;
for (int a = 0; a < list.size(); a++) {
SortableItem item = new SortableItem(view.newChildId());
view.add(item);
item.add(new Label("label", list.get(a)));
}
container.add(view);
}