Issue Details (XML | Word | Printable)

Key: DISPL-501
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Reporter: allan flatoff
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DisplayTag

Column sorting is broken with a decorator

Created: 26/Nov/07 10:58 AM   Updated: 16/Dec/07 04:07 PM   Resolved: 27/Nov/07 08:44 AM
Return to search
Component/s: Paging/Sorting
Affects Version/s: 1.1.1
Fix Version/s: 1.1.1

Time Tracking:
Not Specified

Application server: Tomcat 5.5


 Description  « Hide
I created a column called "Document Title". I created a Table Decorator so I could wrap a URL around the data (since the current linking implementation does not support target="" in the hyperlink).

Example Decorator:

public String getDocumentTitle() {
Row currentRow = (Row)getCurrentRowObject();
String pidString = currentRow.getPidString();
String documentTitle = currentRow.getDocumentTitle();
return "<a href=\"/BPView/docOpener.jsp?pid=" + pidString + "\" target=\"_blank\" class=\"doclinks\"><nobr>" + documentTitle + "</nobr></a>";
}

After doing this, the column no longer sorted on the data that was in my "documentTitle" property, instead it sorted on the TEXT that was put into the documentTitle after the decorator had been applied - so effectively I was sorting on "pidString" instead.

Note that in the current URL linking mechanism, applying a URL does not alter the Sorting. It still sorts on the data from the column instead of the URL that was wrapped around the hyperlink.

Similarly, adding a decoration to a column should not have an effect on the sort. Perhaps there could be an optional parameter sortOnDecoratedColumn or something which would allow you to specify to sort on the actual data or the "decorated data" for the column.

Kevin Conaway added a comment - 26/Nov/07 06:42 PM
Set the sortProperty attribute on the column to be the undecorated value.

If that solves your problem, please close this issue

allan flatoff added a comment - 27/Nov/07 08:41 AM
I altered the decorator to use a different name from the property:

public String getDocumentTitleWithLink() {
Row currentRow = (Row)getCurrentRowObject();
String pidString = currentRow.getPidString();
String documentTitle = currentRow.getDocumentTitle();
return "<a href=\"/BPView/docOpener.jsp?pid=" + pidString + "\" target=\"_blank\" class=\"doclinks\"><nobr>" + documentTitle + "</nobr></a>";
}

**

I then set the table to display the altered property but sort on the real one:

<display:column property="documentTitleWithLink" title="Doc Title" sortable="true" sortProperty="documentTitle" headerClass="sortable"/>

This worked. Much cleaner than a javascript hack I threw together.

Thanks!

allan flatoff added a comment - 27/Nov/07 08:44 AM
There is a workaround - posted in comments

Kevin Conaway added a comment - 27/Nov/07 09:26 AM
You don't even need a decorator for it:

<display:table ... uid="row">
  

  <display:column title="Doc Title" sortable="true" sortProperty="documentTitle" headerClass="sortable">
    <a href="/BPView/docOpener.jsp?pid=${row.pidString}" target="_blank" class="doclinks"><nobr>${row.documentTitle}</nobr></a>
  <display:column>

</display:table>

Thats if you're using the newer servlet versions. Otherwise, you can put <c:out/> tags in for the inline expressions