Forums Register Login

Issue with tomahawk's sorting feature with hyperlink contents

+Pie Number of slices to send: Send
I am using tomahawk's sorting feature using sort attribute for my datatable.

I found one issue while sorting on a hyperlink content in the column. I wanted to sort the table's column based on the title of the hyperlink, but it got sorted based on the whole hyperlink's tag's content also.

Example:
Is there any way that it can only sort based on the title "hashh" (but it got sorted with the whole content inside the generated output from <h:column> tag as hashh )?

Any pointer for the solution will be very much appreciated.

Regards,
Nish
+Pie Number of slices to send: Send
When using tomahawk's sorting feature, if the column bean property object doesn't implement Comparable interface, then they will be sorted as strings.

Like in my application I have to sort a column by email address. But here I want the domain names sorted first. Like:
if I have following ids:
smitha@abc.com
rita@abc.com
amitha@xyz.com
bina@xyz.com

When I sort I get this :

rita@abc.com
smitha@abc.com
amitha@xyz.com
bina@xyz.com

The email property is not just string. Its a Object of a bean called 'EmailBean' (with address and domain properties) which implements Comparable interface, and in compareTo method I compare the domain name and then address.


public String toString(){

return address + "@" + domain;

}
public int compareTo(Object o1) {
EmailBean other = (EmailBean)o1;
if (this.domain.compareTo(other.getDomain()) ==0){
int addressCompare = this.address.compareTo(other.getAddress());
//domain are same then sort on the address
int retVal = ( (addressCompare==0)? 0:((addressCompare>0)?1:-1));
return retVal;
}
else if (this.domain.compareTo(other.getDomain()) > 0){
return 1;
}
else{
return -1;
}
}







Hope this helps

+Pie Number of slices to send: Send
Smitha. Thanks for the Reply.

The actual issue is I am trying to sort base on the <h:outputText value="#{item.name}"/>, but its actually sorted starting with param1=#{item.param1}¶m2=#{item.param2} as those are also dynamic values.

<t:column sortable="true">
<f:facet name="header">
<h:outputText value="Title"/>
</f:facet>

<h:outputLink value="http://mydomain.com/some.jsf?param1=#{item.param1}¶m2=#{item.param2}"
styleClass="linkBlack">
<h:outputText value="#{item.name}"/>
</h:outputLink>
</t:column>

+Pie Number of slices to send: Send
In a outputLink if you want to send parameters you can use <f:param tag (Dot append to the url) something like below:

><h:outputLink value="http://mydomain.com/some.jsf">
<f:param name="param1" value="#{item.param1}"/>
<f:param name="param2" value="#{item.param2}"/>
<h:outputText value="My Link" style="font-size:60%;font-color:lightblue;"/>
</h:outputLink>
Space pants. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1223 times.
Similar Threads
JTabel is not getting rendered properly.
Sorting JTable in asc. or desc.?
TableModel issue in JTable
Sortinng 'h:tableData
Comparator and Compareable
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:47:12.