Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BC93D200CD3 for ; Fri, 28 Jul 2017 13:43:52 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id BABE416CA9A; Fri, 28 Jul 2017 11:43:52 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id DA11816CA98 for ; Fri, 28 Jul 2017 13:43:51 +0200 (CEST) Received: (qmail 61480 invoked by uid 500); 28 Jul 2017 11:43:48 -0000 Mailing-List: contact users-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Discussion" Delivered-To: mailing list users@myfaces.apache.org Received: (qmail 61464 invoked by uid 99); 28 Jul 2017 11:43:46 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Jul 2017 11:43:46 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 56A1C1A1BA5 for ; Fri, 28 Jul 2017 11:43:46 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -2.401 X-Spam-Level: X-Spam-Status: No, score=-2.401 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-2.8, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id Tspw4shXbs1w for ; Fri, 28 Jul 2017 11:43:44 +0000 (UTC) Received: from mail-qk0-f175.google.com (mail-qk0-f175.google.com [209.85.220.175]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id DD68F5FB40 for ; Fri, 28 Jul 2017 11:43:43 +0000 (UTC) Received: by mail-qk0-f175.google.com with SMTP id x191so50872884qka.5 for ; Fri, 28 Jul 2017 04:43:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=IsynIy2LxJx0NBo3YPowPBrzvcNlcuoKz6aINe3poIQ=; b=CnQwHX8l3hJF+ava9KcFF4HRB4rMd4IceWhgcGOlWne6hU9ezmNEP05UOsNmt1hCXR sHmh1d5ybu1AyaBNIUScFfBl/i1n+YjcNZxyqzxij2xDLqLKGXNt0UgXQqKGCmoXbWOD BoNQR1aTJzd8t2MkVhRus37HkGPXRI8X7ZUPlUtwfZ62Q7ehWicKSYisvbkI1F9oaMUD NSD88oZlgSCARm1XSCeZgP8WHamneTCrMz7xf6hvfalksJGstcQXpuX0J/4R+fE7fuxC O9AcuHzxgHYfRsUoRGjrwF3bmo51TMeM09NVMhk9NSwY2BBMRMAsXCBsDZZWEaVC1Cwy G5MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=IsynIy2LxJx0NBo3YPowPBrzvcNlcuoKz6aINe3poIQ=; b=k3wYSkMdV34aYwfmpMHhONxyGBAs3O1gbcG6YNS5GqKtou7rKglwLH8NLA15d3FmkK ApQXZO4zBqDrtiOa10yjmA8+XtEnhwc0cYiVVi+gNw0MjW+iK+9MVFgHtnUSaw5vI4+b OblxQOsL8spATex3FL4Wa6gqLe1nKEsuLn7TTOCvOxV1yglWhbC/imjMir8OIRWHHdIj wYvB+wjNBxv1fzH1rwpUBs0JdeUB5BRIfnKlW1puHMMEgseSfHoD7t7JAdDqCPbu7PUG 4pvHnLqgKQKnKNZAa/PtETPHxcHgl9ZI+pC9vwzOj/J/OdzyQrT8rUWxeHPIhI8dVqkB uB+A== X-Gm-Message-State: AIVw112CKDDfKcgBKB/XKXiIEqUiLa8IO6oCDcQM+jMJvvUgF/PrncT5 a/HVcko8/TipDyTmL++bn5+oNACe+zbw X-Received: by 10.55.53.2 with SMTP id c2mr10005910qka.41.1501242222560; Fri, 28 Jul 2017 04:43:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.109.181 with HTTP; Fri, 28 Jul 2017 04:43:21 -0700 (PDT) In-Reply-To: References: <1500915987.1239.ezmlm@myfaces.apache.org> From: Mike Kienenberger Date: Fri, 28 Jul 2017 07:43:21 -0400 Message-ID: Subject: Re: Tomahawk 20-1.1.14: NestedNullException / BaseSortableModel.sort() contract violation / commandSortHeader and missing custom Comparator To: MyFaces Discussion Content-Type: text/plain; charset="UTF-8" archived-at: Fri, 28 Jul 2017 11:43:52 -0000 We don't currently have any committers actively working on tomahawk. The original JIRA for that was https://issues.apache.org/jira/browse/TOMAHAWK-952 and it looks like I only started to do the groundwork add that support. As this was 10 years ago, I don't really remember any details about it. My clients have long ago switched over to primefaces. I have only one legacy app in maintenance mode that uses tomahawk, so I doubt I will ever revisit working on this. Your best bet is to file a bug and propose a fix in the form of a unified diff. While someone (maybe me) will apply that fix, I don't know if we have any plans to do an official tomahawk release any time soon. From my email, it looks like part of the problem was determining how to maintain backwards compatibility short of subclassing the model. I guess you could try a delegating approach. Sorry, but I doubt I will be of any more help than that. On Tue, Jul 25, 2017 at 8:01 AM, s-awinte wrote: > Hi, > > I'm currently trying to use a Tomahawk tag inside > with auto sorting, similar > to the example here: > https://wiki.apache.org/myfaces/Working_with_auto_sortable_tables > > Problem is, the tag's "propertyName" references to a string property of an > attribute of a given entity object (which itself does not extend > BaseSortableModel) and the entity's attribute is optional (nullable), which > will lead to a NestedNullException: > > ERROR [org.apache.myfaces.component.html.ext.SortableModel]... > org.apache.commons.beanutils.NestedNullException: Null property value for > 'attribute.shortName' on bean class 'class > com.my.app.model.food.exotic.fruit' > ... > javax.faces.FacesException: java.lang.IllegalArgumentException: Comparison > method violates its general contract! > at > javax.faces.component.UIComponentBase$AttributesMap.get(UIComponentBase.java:2352) > ... > Caused by: java.lang.IllegalArgumentException: Comparison method violates > its general contract! > at java.util.TimSort.mergeLo(TimSort.java:777) [rt.jar:1.8.0_60] > at java.util.TimSort.mergeAt(TimSort.java:514) [rt.jar:1.8.0_60] > at java.util.TimSort.mergeCollapse(TimSort.java:439) [rt.jar:1.8.0_60] > at java.util.TimSort.sort(TimSort.java:245) [rt.jar:1.8.0_60] > at java.util.Arrays.sort(Arrays.java:1512) [rt.jar:1.8.0_60] > at java.util.ArrayList.sort(ArrayList.java:1454) [rt.jar:1.8.0_60] > at java.util.Collections.sort(Collections.java:175) [rt.jar:1.8.0_60] > at > org.apache.myfaces.component.html.ext.BaseSortableModel.sort(BaseSortableModel.java:201) > [tomahawk20-1.1.14.jar:1.1.14] > at > org.apache.myfaces.component.html.ext.BaseSortableModel.setComparator(BaseSortableModel.java:62) > [tomahawk20-1.1.14.jar:1.1.14] > at > org.apache.myfaces.component.html.ext.SortableModel.setSortCriteria(SortableModel.java:143) > [tomahawk20-1.1.14.jar:1.1.14] > at > org.apache.myfaces.component.html.ext.AbstractHtmlDataTable.createDataModel(AbstractHtmlDataTable.java:1643) > [tomahawk20-1.1.14.jar:1.1.14] > at > org.apache.myfaces.component.html.ext.HtmlDataTableHack.getDataModel(HtmlDataTableHack.java:932) > [tomahawk20-1.1.14.jar:1.1.14] > at > org.apache.myfaces.component.html.ext.AbstractHtmlDataTable.getDataModel(AbstractHtmlDataTable.java:1597) > [tomahawk20-1.1.14.jar:1.1.14] > at > org.apache.myfaces.component.html.ext.HtmlDataTableHack.getRowCount(HtmlDataTableHack.java:103) > [tomahawk20-1.1.14.jar:1.1.14] > at sun.reflect.GeneratedMethodAccessor32969.invoke(Unknown Source) > [:1.8.0_60] > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > [rt.jar:1.8.0_60] > at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_60] > ... > > > As I understand it, the row Objects of a sortable column are > being automatically wrapped in SortableModel, which brings its own > "RowDataComparator" via BaseSortableModel.sort(), which seems to be > > a) not null-safe (for the wrapped model) > b) not supporting nulls first/last > c) in this case violating the Comparator contract > > Regardless of the contract violation problem (probably due to a > NestedNullException inside RowDataComparator or because > BaseSortableModel.sort() never returning -1), I'd like in general to be able > to use a custom Comparator here, which can handle nested nulls and > implements a customized comparison, but does not seem > to support this. > > Most references I find, completely ignore the commandSortHeader auto-sorting > and do the implement a custom backing Bean.sort(), an approach I'd like to > avoid, if possible. > > There would seem to exist a solution for the problem in this somewhat dated > example here, but it's unclear to me, if it ever managed to make it into > tomahawk's code base: > http://grokbase.com/t/myfaces/dev/073ev810b8/sortablemodel-and-t-datatable-changes-improvements > > In Trinidad, it would seem, that there was a similar (now resolved) issue: > https://issues.apache.org/jira/browse/TRINIDAD-1965 > > I could not figure out how this applies to Tomahawk, though, or if the > example above has been implemented by now, and I could not find any working > code example that would support this assumption. > > Also, I do not see how SortableModel.setSortCriteria() -> > BaseSortableModel.setComparator() could be utilized in this scenario without > letting the entity model extend BaseSortableModel or SortableModel, which > seems not feasable, due to my model already extending several other classes. > Is using a custom Comparator not supported in Tomahawk still, or, if so, > where can I find code examples or documentation describing how to use this > feature? > > If not, are you planning on fixing this issue anytime soon and should I file > a bug about the NestedNullException / contract violation problem, too? > > > Best regards, > Sawin