You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Christian Mühlethaler <ch...@freesurf.ch> on 2004/12/11 21:45:56 UTC
[Solved] Re: comparator in iTable column
ok, the solution was obvious:
take AbstractTableColumn#setComparator(comparator). This comparator
takes the objRow for comparing.
SimpleTableColumn#setColumnComparator(columnComparator) is for sorting
the objColumn's value.
Sorry about the noise.
Christian
> Hi list,
>
> has somebody knows how to compare dates in contrib:Table?
> I can't make it run properly.
>
> I have a table of objects of type Issue that has a date property:
> creationDate
> the table does compare this date as String representation, as they are
> showed in the creationDate column.
>
> So I added a customized comparator to my simpleTableColumn.
> But the comparator's compare throws a ClassCastException: the two
> arguments are of type String,
> not as expected of the type "Issue".
>
> It compares the columnValue of getColumnValue() rather than the object
> itself.
>
> any ideas?
> thank you,
> Christian
>
>> ...
>> ITableColumn column1 = new SimpleTableColumn("creationDate",
>> "Erstellt",
>> new ITableColumnEvaluator(){
>> public Object getColumnValue(ITableColumn objColumn,
>> Object objRow) {
>> return
>> fh.helper.Util.format(((Issue)objRow).getCreationDate());
>> }
>>
>> },true);
>>
>> ((SimpleTableColumn)column1).setColumnComparator(this.getDAOFactory().
>> getIssueDAO().getCreationDateComparator());
>> ...
>
>> private class CreationDateComparator implements Comparator {
>>
>> public int compare(Object o1, Object o2) {
>> log.warn("compare: " +o1.getClass().getName()+", value =
>> "+o1.toString());//<-- java.lang.String.
>> //Issue i1 = (Issue)o1; //<-- ClassCastException
>> //Issue i2 = (Issue)o2;
>> //return
>> i1.getCreationDate().compareTo(i2.getCreationDate());
>> return 0;
>> }
>>
>> }
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org