Anybody a great idea for changing item order in a sorted set using the
wicket viewer? I have a rank-property in the database but how to easily
manage the item order (move item(s) up/down single or multiple places)...
Erik de Hair 's gravatar image asked Mar 17 2015 at 08:43 in Isis-Users by Erik de Hair

10 Answers

Hi Erick.
Simply by implementing the Comparable interface.
GESCONSULTOR 's gravatar image answered Mar 17 2015 at 09:39 by GESCONSULTOR
And also, you can write a custom comparator and reference it
Dan Haywood 's gravatar image answered Mar 17 2015 at 09:48 by Dan Haywood
Hi Oscar, Dan,
I think my question wasn't really clear. The ordering in the table is
not the problem (I've already implemented the comparable interface based
I need to arbitrarily change the order of the items by moving an item up
or down in the list (this should change the rank values). I was
wondering if anybody had an idea or any experience with an elegant way
to implement the moving-actions to be executed by the user.
Erik de Hair 's gravatar image answered Mar 17 2015 at 10:17 by Erik de Hair
Maybe you can use the Bulk support - select few items in the table, then
click Up/Down action and depending on the action increase/decrease the rank
of the selected items.
Martin Grigorov
Freelancer, available for hire!
Wicket Training and Consulting
Martin Grigorov 's gravatar image answered Mar 17 2015 at 13:16 by Martin Grigorov
Hi Martin,
I thought your idea would be a nice solution but there's one problem
when moving succeeding items down. Each pair of items will switch ranks
than but won't move down. This could be solved by moving items down
while beginning at the bottom of the sorted set, but I don't think I can
influence the order in which the bulk actions are called to the single
items, do I?
I can't expect users to only select 'solitary' items and I think it's
not possible to check for that condition.
Would it be possible to create a different view for a datatable which
displays the items (implementing some interface with methods like
'rankUp/Down()') with 2 buttons per row for moving a single item up or
down, by calling rankUp/Down of this item?
Erik de Hair 's gravatar image answered Mar 18 2015 at 01:46 by Erik de Hair
Everything is possible!
The fastest and easiest way (for me!) would be to create a custom component
factory that creates a custom component for objects implementing this
special/custom interface and renders them as you wish. But this is me
thinking as a Wicket developer. Maybe Dan will have a better Isis solution
for the problem.
Martin Grigorov 's gravatar image answered Mar 18 2015 at 02:06 by Martin Grigorov
I've had two ideas on this.
The first is very generic... allow no-arg actions to be rendered as buttons
would update state to change its apparent ordering). The viewer would then
re-render the same collection in the same way it does currently for bulk
actions (by invoking the finder that returned the list).
The other idea is a little more specialized; introduce a new Movable
interface into the applib, eg:
public interface Movable {
void moveBetween(Object before, Object after);
Then, enhance the Wicket viewer so that "movable" objects could be dragged
up and down; on release the viewer would invoke the "moveBetween" method
passing the objects before and after the drop zone, and then (as above)
re-render the list.
If either of these appeals then raise a ticket (actually, I think there
might be one already for the first idea).
In terms of actually implementing these tickets, I have no plans myself but
Martin (as our resident Wicket expert) might either (a) oblige or (b)
provide some guidance.
Dan Haywood 's gravatar image answered Mar 18 2015 at 03:43 by Dan Haywood
This would be very nice to have. This reduces the amount of clicks to be
performed by the user very much.
For updating ranks, I would prefer this solution.
I will raise a ticket for both solutions.
Erik de Hair 's gravatar image answered Mar 18 2015 at 07:17 by Erik de Hair
Hi Martin,
Although I think Dan's solutions would be better for the future I your
solution of the custom component would help me out for now.
After looking at the Excel and Gmap3 add ons I managed to get the
collection with items (implementing the RankEditable interface with
methods moveUp() and moveDown()) rendered. Now I need to add the actions
to the datatable but have no idea how to create an action that acts on
the underlying entity. I used Wicket's DataView-class to render the
table. Could you give me some hints how to do this?
Erik de Hair 's gravatar image answered Mar 18 2015 at 07:25 by Erik de Hair
Hi Dan,
That helped: I managed to put a button in each row. It's the first step,
some steps left to take :-)
Erik de Hair 's gravatar image answered Mar 25 2015 at 05:21 by Erik de Hair