You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "t.n.a." <tn...@sharanet.org> on 2005/03/19 12:01:40 UTC

contrib:table - sorting localisation issue

I use the basic table component and need sorting by certain columns. It 
works out-of-the-box with english alphabet letters, but all the 
regional-specific letters are pushed back after all the other letters.
How do I specify a collation? Is this a Tapestry issue, in the first place?

Tomislav

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: contrib:table - sorting localisation issue

Posted by "t.n.a." <tn...@sharanet.org>.
Mind Bridge wrote:

>Hi,
>
>There are a number of possible approaches you can take
>
>1) By default, the values given by the column's OGNL expression are used to
>perform the sorting. Rather than a String, you could return a Comparable
>[...]
>
>2) In the 'columns' parameter, define your column as '=myColumn' and add a
>method 'getMyColumn()' to your page (change myColumn to what you want).
>[...]
>
Thank you for the effort M.B., but I've concluded that these are just 
workarounds, not applicable every time I need sorting of non-english 
strings: I probably should have formed my question better.

I deduced that what I really need is to leave the sort to the database, 
where collation is already set up, so I need to implement 
IBasicTableModel in my data source as described at 
http://jakarta.apache.org/tapestry/doc/ComponentReference/contrib.TableView.html, 
the second solution.

The problem now is, the documentation on implementing IBasicTableModel 
seems to be very scarce and I'm stuck here:

public class ResultsModel implements IBasicTableModel {
  
    public int getRowCount () {
        //return what?
    }

    public Iterator getCurrentPageRows(int nFirst, int nPageSize, 
ITableColumn objSortColumn, boolean bSortOrder) {
       //return what?
    }
}

Basically, I'd appreciate a simple (or, at most, moderately complex) 
example of such class. I've tried searching Tapestry sources for 
"implements IBasicTableModel" but haven't really gotten anywhere with that.

TIA,
Tomislav

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: contrib:table - sorting localisation issue

Posted by Mind Bridge <mi...@yahoo.com>.
Hi,

There are a number of possible approaches you can take

1) By default, the values given by the column's OGNL expression are used to
perform the sorting. Rather than a String, you could return a Comparable
wrapper of the string that uses the collator you want, e.g. by defining the
column as "myColumn:new MyWrapper(myColumnValue)". The column will be sorted
according to the rules set in the compareTo() method of the wrapper. If you
do not use a custom Block to define the presentation, make sure that you
override toString() as well to return the string.

2) In the 'columns' parameter, define your column as '=myColumn' and add a
method 'getMyColumn()' to your page (change myColumn to what you want).
Return an object of type ITableColumn, probably an ExpressionTableColumn,
which has simple constructors only with the column name and the OGNL
expression. Before you return it, you can do setColumnComparator() on it
with your collator. Also, make sure you call loadSettings(this) if you want
it to pick up any relevant Blocks or localization information. To put it in
code:

public ITableColumn getMyColumn() {
    ExpressionTableColumn column = new ExpressionTableColumn("myColumn",
"columnExpression");
    column.setColumnComparator(Collator.getInstance(getLocale()));
    column.loadSettings(this);
}


There are other ways too, but I guess those may help.

Best regards,
-mb

----- Original Message ----- 
From: "t.n.a." <tn...@sharanet.org>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Saturday, March 19, 2005 1:01 PM
Subject: contrib:table - sorting localisation issue


> I use the basic table component and need sorting by certain columns. It
> works out-of-the-box with english alphabet letters, but all the
> regional-specific letters are pushed back after all the other letters.
> How do I specify a collation? Is this a Tapestry issue, in the first
place?
>
> Tomislav
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org