Board index JavaServer Faces General p:orderList for classes that implement comparable

p:orderList for classes that implement comparable

Components, Ajax Framework, Utilities and More.


Posts: 13
The component is pretty neat and all, but it only works if you're ordering a list of Strings. Fair enough, you can pass any collection to it and it will convert the elements to a String (through a converter or the toString() method). The problem that I have is that I'd like to order my list of objects that implement the Comparable interface. When I process the commandButton to get the ordered list, my original list goes from being List<MyObject> to List<String>. The weird thing is that it's declared as a list of MyObject. Primefaces is actually changing the type of my list. Weird.

Anyway, I understand the implications of enforcing only comparable objects in the component, but I think it would make the orderList much more powerful. Read a list from the DB, for example, order the elements using p:orderList, store the order back in the DB.


Posts: 15071
Location: Cybertron

OrderList support pojos not just string, for pojos you need a converter, component's responsibility not to sort your data but provide the UI for your users to sort it manually.
PrimeFaces Lead


Return to General