I searched an archive of the list and the closest I have come to the problem I 
am having is this (which pretty much describes my problem):

http://www.mail-archive.com/displaytag-user@lists.sourceforge.net/msg06493.html
http://www.mail-archive.com/displaytag-user@lists.sourceforge.net/msg06493.html

Except I am not using the EL TLD.

In short, I have written a compartor, I have set the comparator property for a 
column, but the compare() method is never being called.

Here is what I have. The relevant part of the table:

<jsp:root version="1.2" xmlns:jsp="http://java.sun.com/JSP/Page"; 
                        xmlns:display="urn:jsptld:http://displaytag.sf.net";
                        xmlns:c="urn:jsptld:http://java.sun.com/jstl/core_rt";>
  <jsp:directive.page contentType="text/html; charset=UTF-8" />

 <display:table name="contracts" id="row" uid="contract" defaultsort="1" 
defaultorder="descending" class="simple" 
requestURI="indexReport.htm?report=salesReport.htm">
 
<display:column property="startDate" sortable="true" headerClass="sortable"  
title="Contract Start" 
        decorator="mypackage.displaytag.ContractStartDateWrapper"
        comparator="mypackage.displaytag.ContractStartDateComparator"/>

>> more columns

The comparator.

public class ContractStartDateComparator extends DefaultComparator
{

    private static final Log LOG = 
LogFactory.getLog(ContractStartDateComparator.class);

public ContractStartDateComparator()
{
        super();
        LOG.debug(" >>>>>>>>>>>> constructor called! <<<<<<<<<<<");
}

public int compare(Object objectLhs, Object objectRhs) 
{
        LOG.debug(" >>>>>>>>>>>> lhs = " + objectLhs + " rhs " + objectRhs);

    // return some int from compare logic here.
}

Although I am seeing log statements from my decorator, I see no log statements 
from the compare method of my comparator when display the table or when I click 
on the column to change the order. The constructor is being called because I 
get a log statement from it, but not the compare method. I haven't spelunked 
into the DisplayTag code yet - I was hoping that there was something obvious to 
the list about what I am doing wrong because I have seen where other people 
referenced using custom comparators and therefore *somebody* got them to work. 
Right?

Just a thought - the decorator is called before the comparator - right? Because 
I am decorating a date property that can be null - if it is null I return 
"ASAP", if not null I return the date as a string.

Any help appreciated. I found this very late in a dev cycle too late because 
the default sort order was what I was expecting and my unit tests worked fine 
with the comparator itself, but now the req is that the sort order be reversed 
and I am unable to comply.

Thanks in advance.


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
displaytag-user mailing list
displaytag-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to