p:orderList for classes that implement comparable

Components, Ajax Framework, Utilities and More.
Post Reply
Posts: 13
Joined: 29 Mar 2011, 15:43

28 Oct 2011, 21:46

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.

User avatar
Posts: 17554
Joined: 05 Jan 2009, 00:21
Location: Cybertron

29 Oct 2011, 11:18

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.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 7 guests