You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Th...@usitc.gov on 2006/11/01 17:55:40 UTC

Getting the ordinal # in the Contrib:Table

I *hope* there's a really straightforward answer to this and that I'm
just a complete donkey for overlooking it, but. . . 

If you want to have a table that iterates over a List and (for example)
spit out some properties of each element in the List, to wit:

---------------------------
|Aaron |	(202) 123-4567|
---------------------------
|Bob   |	(202) 987-6543|
---------------------------
etc.etc.

That's really easy.

But now say you want to just add an ordinal number as the first column
of the table, like this:

---------------------------------
| 1 | Aaron |	(202) 123-4567|
---------------------------------
| 2 | Bob   |	(202) 987-6543|
---------------------------------	
| 3 | etc. etc.

That seems to be harder.  The only way I see how to do it is to:

A) Define a custom columnValue @Block

B) Map that columnValue to some MyTable.java getOrdinal() method

C) In my getOrdinal() method, get the Object associated with
getTable().getTableRow();

D) Assume the "source" data for the Table is a java.util.List, use the
List.indexOf() method on the Object from step (C) to figure out what
element it is and return that int value as the ordinal 

Please tell me I'm a donkey...

Thanks,
Tom

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


Re: Getting the ordinal # in the Contrib:Table

Posted by Shing Hing Man <ma...@yahoo.com>.
The method 
getCurrentPages in
org.apache.tapestry.contrib.table.components.TablesPages

returns the current page of  your table.

The ordinal number of  the first row of the current
page should be something like 

(tablesPages.getCurrentPage() - 1) * PAGE_SIZE) + 1


Shing


--- Thomas.Vaughan@usitc.gov wrote:

> I *hope* there's a really straightforward answer to
> this and that I'm
> just a complete donkey for overlooking it, but. . . 
> 
> If you want to have a table that iterates over a
> List and (for example)
> spit out some properties of each element in the
> List, to wit:
> 
> ---------------------------
> |Aaron |	(202) 123-4567|
> ---------------------------
> |Bob   |	(202) 987-6543|
> ---------------------------
> etc.etc.
> 
> That's really easy.
> 
> But now say you want to just add an ordinal number
> as the first column
> of the table, like this:
> 
> ---------------------------------
> | 1 | Aaron |	(202) 123-4567|
> ---------------------------------
> | 2 | Bob   |	(202) 987-6543|
> ---------------------------------	
> | 3 | etc. etc.
> 
> That seems to be harder.  The only way I see how to
> do it is to:
> 
> A) Define a custom columnValue @Block
> 
> B) Map that columnValue to some MyTable.java
> getOrdinal() method
> 
> C) In my getOrdinal() method, get the Object
> associated with
> getTable().getTableRow();
> 
> D) Assume the "source" data for the Table is a
> java.util.List, use the
> List.indexOf() method on the Object from step (C) to
> figure out what
> element it is and return that int value as the
> ordinal 
> 
> Please tell me I'm a donkey...
> 
> Thanks,
> Tom
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail:
> users-help@tapestry.apache.org
> 
> 


Home page :
  http://uk.geocities.com/matmsh/index.html

Send instant messages to your online friends http://uk.messenger.yahoo.com 

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