Hi Ted,
Use getTableColumnChildren to get an iterator of the TableColumns. Get
your coulmn from the iterator. Use the setSort method on the
TableColumn to set the sort object to a parameter that you set up in the
page bean. In the parameter's getter method return whatever value you
like to sort the column by. In the getter, use {currentRow.yourValue}
to get the a value from the table that you want to sort by. If it is
NULL return "AAAAAAA" or "ZZZZZZZ" depending on whether the order is
ascending or descending (assuming you are sorting Strings, appropriate
numbers otherwise).
Hope this helps!
Rick
TedByers wrote:
> In JDK6/NetBeans 1.0.1
>
> We have almost everything working with our tables. Initially we had issues
> with formatting text displayed, and exceptions thrown when a result obtained
> through JDBC contained nulls in certain fields. We handled all that with
> new numeric classes derived from existing classes such as Double. Our
> derived classes provide support for nulls, with a rational display string
> (to indicate that for the record displayed, there is no applicable data for
> the column in question). We even got the table to display negative values
> in red and sort so that nulls appear at the end of the list when sorting in
> descending order!
>
> But there is a problem. With the current state, if we sort in ascending
> order, records with nulls appear at the top of the table. What we need is
> the ability to place records with nulls in the column on which we're sorting
> always at the end of the sequence, never the beginning, regardless of
> whether we're sorting in ascending or descending order.
>
> Logically, nulls in this context correspond to NaNs in numeric computation.
> Null means there is no relevant data, and so is neither greater than nor
> less than any numeric value (which theoretically could take any real number,
> so dummy values are always both useless and invalid).
>
> If I were writing this in C++, I would have a boolean data member to reflect
> whether or not the instance has a null value, and implement my own
> relational operators that guarantee that instances with a null value always
> appear at the end of the sequence produced by a sort, regardless of whether
> we're sorting in ascending or descending order! While this is trivially
> easy to do using C++'s STL, it isn't clear to me whether it is equally easy
> using Java's container classes (although it should be if I wanted to put the
> effort into implementing my own container classes).
>
> Using the comparator interface would be an option IFF we could tell the
> comparator whether we are sorting in ascending or descending order, since
> our implementation would use that along with the boolean reflecting whether
> or not the object is null to provide a return value that guarantees the
> correct placement of the object. But that interface has no overload to pass
> that information along to the objects being sorted, and it isn't clear how
> we'd get an overload WE provide to be used by the table, or even how we'd
> find out at run time which order is to be used.
>
> We have found out about "com.sun.data.provider.impl.BasicTableDataSorter",
> but it is not yet clear how to use it to acheive our objective, or even know
> if it we CAN use it to solve our problem. We do not want to reimplement the
> existing sorting behaviour of the JSF tables, or the data provider. The
> logical place for the change we want to make is in the comparator, but at
> the moment THAt seems to be too rigid to help us.
>
> Any suggestions on how best to proceed would be appreciated.
>
> Thanks
>
> ted
>
---------------------------------------------------------------------
To unsubscribe, e-mail:
users-unsubscribe@...
For additional commands, e-mail:
users-help@...