Droplist Element Sorting

10 views
Skip to first unread message

Jack

unread,
Apr 29, 2012, 10:27:05 AM4/29/12
to jmesa_forum
I extended the DropListFilter editor and it seems to work fine except
that the items are sorted by key/value rather than label. I inserted
the items in the list in label order. Is the sorting done
automatically by jMesa? I have verified that the ArrayList returned by
the method below is in the proper sequence.

I'm stumped.

protected class BlockDroplistFilterEditor extends
DroplistFilterEditor {
@Override
protected List<Option> getOptions() {
List<Option> options = new ArrayList<Option>();
List<Block> blocks = distributionService
.getBlocks();
for (Block block : blocks) {
options.add(new Option(block.getId().toString(),
block.getTitle()));
}
return options;
}
}

Jeff Johnston

unread,
Apr 29, 2012, 12:26:45 PM4/29/12
to jmesa...@googlegroups.com
If you override the  getOptions() then you would need to sort the collection with the following:

Collections
.sort(opts, null);

The Option class implements Comparable and sorts off of the label.


http://code.google.com/p/jmesa/source/browse/trunk/jmesa/src/org/jmesa/view/html/editor/DroplistFilterEditor.java

-Jeff Johnston
Reply all
Reply to author
Forward
0 new messages