Bugfix
Major
#28197
Sorting a composition table by a column with SelectField leads to ClassCastException
If a composition attribute is displayed as a table in a form, sorting this table by columns containing a tl:SelectField fails. An error message is displayed and sorting is deactivated for this table.
The problem can be reproduced in the demo with a suitable model and form. On the demo test server, for example, in the Technical Demo > Tests > Jan view when sorting by the "Select" column.
Analysis
The cause appears to be that the SelectField contains a SingletonList as a value. However, the tl:WrapperNameComparator expects a single tl:TLObject in the signature of its compare method.
Stacktrace
Caused by: java.lang.ClassCastException: class java.util.Collections$SingletonList cannot be cast to class com.top_logic.model.TLObject at com.top_logic.knowledge.wrap.WrapperNameComparator.compare(WrapperNameComparator.java:27) at com.top_logic.basic.col.ComparatorProxy.compare(ComparatorProxy.java:110) at com.top_logic.basic.col.NullSafeComparator.compare(NullSafeComparator.java:108) at com.top_logic.basic.col.MappedComparator.compare(MappedComparator.java:150) at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355) at java.base/java.util.TimSort.sort(TimSort.java:220) at java.base/java.util.Arrays.sort(Arrays.java:1307) at java.base/java.util.ArrayList.sort(ArrayList.java:1721) at java.base/java.util.Collections.sort(Collections.java:179) at com.top_logic.layout.table.model.SimpleTableModelStructure.revalidateOrder(SimpleTableModelStructure.java:136) at com.top_logic.layout.table.model.ObjectTableModel.revalidateOrder(ObjectTableModel.java:180) at com.top_logic.layout.table.model.AbstractObjectTableModel.setOrder(AbstractObjectTableModel.java:84) at com.top_logic.layout.table.TableViewModel.validate(TableViewModel.java:1355) ... 53 more
test
- /com.top_logic.demo/src/test/java/test/com/top_logic/demo/scripted/model/attribute/composition/TestSortingCompositionTable.script.xml