File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Question on how to sort tomahawk datatable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Question on how to sort tomahawk datatable" Watch "Question on how to sort tomahawk datatable" New topic

Question on how to sort tomahawk datatable

Abdul Shams

Joined: Oct 12, 2008
Posts: 6
Hello All,

I'm new to this forum and am stuck in getting tomahawk datatable to sort columns for me.

From searching the web I understood that sortAscending and sortColumn properties should point to properties in the backing bean. For some reason that does not work!!

HELP me I've looked everywhere

My datatable code is :

and my backing bean code is:

Is there something that needs to be written in the methods? help me out here guys
Abdul Shams

Joined: Oct 12, 2008
Posts: 6
Help! Anyone!!
Darryl Nortje
Ranch Hand

Joined: Jun 11, 2002
Posts: 140
Hey Abdul,

I've done this in the past, but not with tomahawk dataTable. So perhaps this might not help, but then again, maybe it does.

I used myFaces dataTable. And I just sorted the List on the backing bean. So in the header of the column I have 2 commands (little up and down arrows) that call a sortXXXAscending or sortXXXDescending method on the backing bean. Then this method just uses the Collections.sort method to sort the actual List containing the data.

This worked fine for me, hope it helps for you.

Juan Pablo Rostra

Joined: Oct 12, 2008
Posts: 2
You dont really need to link those properties with your backing bean. Try something like this (replacing capital text with your values):

The real trick is the tag t:commandSortHeader
Abdul Shams

Joined: Oct 12, 2008
Posts: 6
Thanks Darryl but I thought I'd use it as a last resort. I'm hoping to get the tomahawk way correct which would save a lot of effort i think.

Juan, Thank you as well for your reply but I can't get it to work! Does it have something to do with that I'm using an ArrayList as my datasource?

Here is my ammended datatable

Funny thing is that the arrows don't seem to appear as well!

Guys any help would be really appreciated..

[ October 19, 2008: Message edited by: Abdul Shams ]
James Tillman

Joined: Sep 08, 2008
Posts: 2
WITHIN your backing bean you must have this:

"sortAscending" must be of type boolean with methods:

public boolean isSortAscending() {
return sortAscending;

public void setSortAscending(boolean sortAscending) {
this.sortAscending = sortAscending;

"sortColumn" must be of type String with methods:
public String getSortColumn() {
return sortColumn;

public void setSortColumn(String sortColumn) {
this.sortColumn = sortColumn;

With both of those ALONE you will get the default sort which works when you click on the header title. You can test this by places breakpoints on the setter and you will see values getting set.

To do customized sorting you have to do it on the t:column level (I think). Take a look at what t:column has to offer as attributes.

As for me I'm learning this for the very first time right now but so far what I have told you works for me.

Thank you,
I agree. Here's the link:
subject: Question on how to sort tomahawk datatable
It's not a secret anymore!