DisplayTag with dynamic link sorting irratically

1.9k views Asked by At

I'm hoping someone can help me with my DisplayTag problem. This is my current java JSP code

<display:column property="code" titleKey="order.list.header.code" sortable="true" />
<display:column titleKey="title.describe" sortable="false">
<a class="item" href="javascript:open('<html:rewrite page='/action/product'/>?action=viewProduct&amp;id=<bean:write name='productMissing' property='id'/>',
                                      '<bean:message key='button.label.close' />');">
    <bean:write name="productMissing" property="description" />
    <br />
    <bean:write name="productMissing" property="details" />
</a>                            
</display:column>

With the code above, everything shows up fine. The link is fine and the values are correct. But if I set the "sortable" flag to true, and click on the "title.describe" header, the sort makes no sense.

I tried putting the description inside the display:column tag like this

<display:column property="description" titleKey="title.describe" sortable="true" />

the sort worked but I'm still missing the "a href" and the second property "details".

So I tried the same line above but added Displaytag's property href as described in the displaytag site like this.

<display:column property="description" titleKey="title.describe" href="javascript:open('<html:rewrite page='/action/product....."  sortable="true" />

But the link was not built properly. I suspect because the link calls a javascript function or because of the struts tags.

I'm at a loss here. Any help or ideas would be appreciated.

1

There are 1 answers

0
Asfab On

You need to give attribute defaultsort in display:table with the number of column to be sorted

<display:table id="row" name="table.name" class="displaytag" defaultsort="2" 
                        defaultorder="descending" sort="list">

EDIT

You can give sortProperty to display:column and give using which property you want to sort description or details

<display:column titleKey="title.describe" sortable="true" sortProperty="description">                          
</display:column>