You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Udo Schnurpfeil (JIRA)" <de...@myfaces.apache.org> on 2019/01/09 17:33:00 UTC
[jira] [Commented] (TOBAGO-1972) Sheet sorting: can't sort "Apples
with Pears"
[ https://issues.apache.org/jira/browse/TOBAGO-1972?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16738461#comment-16738461 ]
Udo Schnurpfeil commented on TOBAGO-1972:
-----------------------------------------
Problem exists until 4.0.0
> Sheet sorting: can't sort "Apples with Pears"
> ---------------------------------------------
>
> Key: TOBAGO-1972
> URL: https://issues.apache.org/jira/browse/TOBAGO-1972
> Project: MyFaces Tobago
> Issue Type: Bug
> Components: Core
> Affects Versions: 4.3.2
> Reporter: Udo Schnurpfeil
> Assignee: Udo Schnurpfeil
> Priority: Minor
>
> It's not possible to sort (and compare) a list of objects using the same interfaces. Example:
> {code}
> <tc:sheet value="#{fruitBasket.list}" var="fruit">
> <tc:column label="Name" sortable="true">
> <tc:out value="#{fruit.name}"/>
> </tc:column>
> </tc:sheet>
> {code}
> {code}
> import javax.enterprise.context.RequestScoped;
> import javax.inject.Named;
> import java.io.Serializable;
> import java.util.ArrayList;
> import java.util.List;
> @Named
> @RequestScoped
> public class FruitBasket implements Serializable {
> private List<Fruit> list;
> public FruitBasket() {
> list = new ArrayList<>();
> list.add(new Apple("Golden Delicious"));
> list.add(new Apple("Schöner aus Boskoop"));
> list.add(new Pear("Williams Christ"));
> list.add(new Pear("Köstliche aus Charneux"));
> }
> public List<Fruit> getList() {
> return list;
> }
> }
> {code}
> {code}
> public interface Fruit {
> String getName();
> void setName(String name);
> }
> {code}
> {code}
> public class Apple implements Fruit {
> private String name;
> public Apple(String name) {
> this.name = name;
> }
> @Override
> public String getName() {
> return name;
> }
> public void setName(String name) {
> this.name = name;
> }
> }
> {code}
> {code}
> public class Pear implements Fruit {
> private String name;
> public Pear(String name) {
> this.name = name;
> }
> @Override
> public String getName() {
> return name;
> }
> public void setName(String name) {
> this.name = name;
> }
> }
> {code}
> Excepiton:
> {code}
> 45,350 ERROR m.t.u.BeanComparator:95 java.lang.ClassCastException@61e93129
> java.lang.IllegalArgumentException: java.lang.ClassCastException@61e93129
> at sun.reflect.GeneratedMethodAccessor87.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at org.apache.myfaces.tobago.util.BeanComparator.compare(BeanComparator.java:93)
> at java.util.TimSort.binarySort(TimSort.java:296)
> at java.util.TimSort.sort(TimSort.java:221)
> at java.util.Arrays.sort(Arrays.java:1512)
> at java.util.ArrayList.sort(ArrayList.java:1462)
> at java.util.Collections.sort(Collections.java:175)
> at org.apache.myfaces.tobago.component.Sorter.perform(Sorter.java:182)
> at org.apache.myfaces.tobago.component.Sorter.perform(Sorter.java:84)
> [...]
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)