Sorting is performed on the original List
. If it is read-only, an exception is thrown. Try the same thing, but with a regular, mutable List
EDIT: create a regular list in a bean:
public class MyBean { ... List<MyObject> myList = new ArryList<MyObject>(); myList.add(new MyObject("a")); myList.add(new MyObject("b")); myList.add(new MyObject("c")); ...
then use sorting as follows: value="#{myBean.myList}" var="myVar" sortBy="#{myVar.stringProp}"
EDIT2: If the sort options are strings or numbers, you do not need to configure anything. If you are sorting anything else, you will need to define a custom sortFunction function,
If you use advanced options such as lazy loading (which was broken into bfw in pf 3.2 - you can now upgrade to 3.3), it was released 29.5 and allegedly solved it), you will have to define the user model, taking care about filtering and sorting.
So, if you want to sort your data by the contents of the array, you will need to define the attribute sortFunction="#{myBean.sortData()}"
source share