myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <>
Subject Re: Tomahawk 20-1.1.14: NestedNullException / BaseSortableModel.sort() contract violation / commandSortHeader and missing custom Comparator
Date Fri, 28 Jul 2017 11:43:21 GMT
We don't currently have any committers actively working on tomahawk.

The original JIRA for that was 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

>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 <t:commandSortHeader> Tomahawk tag inside
> <t:column defaultSorted="true" sortable="true"> with auto sorting, similar
> to the example here:
> 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
> ...
> javax.faces.FacesException: java.lang.IllegalArgumentException: Comparison
> method violates its general contract!
> at
> javax.faces.component.UIComponentBase$AttributesMap.get(
> ...
> Caused by: java.lang.IllegalArgumentException: Comparison method violates
> its general contract!
>     at java.util.TimSort.mergeLo( [rt.jar:1.8.0_60]
>     at java.util.TimSort.mergeAt( [rt.jar:1.8.0_60]
>     at java.util.TimSort.mergeCollapse( [rt.jar:1.8.0_60]
>     at java.util.TimSort.sort( [rt.jar:1.8.0_60]
>     at java.util.Arrays.sort( [rt.jar:1.8.0_60]
>     at java.util.ArrayList.sort( [rt.jar:1.8.0_60]
>     at java.util.Collections.sort( [rt.jar:1.8.0_60]
>     at
> org.apache.myfaces.component.html.ext.BaseSortableModel.sort(
> [tomahawk20-1.1.14.jar:1.1.14]
>     at
> org.apache.myfaces.component.html.ext.BaseSortableModel.setComparator(
> [tomahawk20-1.1.14.jar:1.1.14]
>     at
> org.apache.myfaces.component.html.ext.SortableModel.setSortCriteria(
> [tomahawk20-1.1.14.jar:1.1.14]
>     at
> org.apache.myfaces.component.html.ext.AbstractHtmlDataTable.createDataModel(
> [tomahawk20-1.1.14.jar:1.1.14]
>     at
> org.apache.myfaces.component.html.ext.HtmlDataTableHack.getDataModel(
> [tomahawk20-1.1.14.jar:1.1.14]
>     at
> org.apache.myfaces.component.html.ext.AbstractHtmlDataTable.getDataModel(
> [tomahawk20-1.1.14.jar:1.1.14]
>     at
> org.apache.myfaces.component.html.ext.HtmlDataTableHack.getRowCount(
> [tomahawk20-1.1.14.jar:1.1.14]
>     at sun.reflect.GeneratedMethodAccessor32969.invoke(Unknown Source)
> [:1.8.0_60]
>     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> [rt.jar:1.8.0_60]
>     at java.lang.reflect.Method.invoke( [rt.jar:1.8.0_60]
>     ...
> As I understand it, the row Objects of a sortable <t:dataTable> 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 <t:commandSortHeader> 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:
> In Trinidad, it would seem, that there was a similar (now resolved) issue:
> 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

View raw message