• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue with tomahawk's sorting feature with hyperlink contents

 
joshua asem
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Smitha H Rao
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
joshua asem
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Smitha. Thanks for the Reply.

The actual issue is I am trying to sort base on the <hutputText 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">
<hutputText value="Title"/>
</f:facet>

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

 
Smitha H Rao
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a outputLink if you want to send parameters you can use <f:param tag (Dot append to the url) something like below:

><hutputLink value="http://mydomain.com/some.jsf">
<f:param name="param1" value="#{item.param1}"/>
<f:param name="param2" value="#{item.param2}"/>
<hutputText value="My Link" style="font-size:60%;font-color:lightblue;"/>
</hutputLink>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!