You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jim O'Callaghan <ji...@peritussolutions.com> on 2010/07/15 23:07:21 UTC

t:grid, inPlace and rowIndex

Is there an in-built solution for a row index in the t:grid that survives
sorting and works with inPlace="true" - I'm currently getting the error
"Component X/Y/Zs is not rendering, so render variable 'rowIndex' may not be
updated upon sorting".  I'm trying to get something that tells me the
current index of the item in a list the grid is displaying, and need the
index to *not* be updated during sorting.  Is this only possible with a
representation on the entity the grid is displaying?

 

Thanks,

Jim.


Re: t:grid, inPlace and rowIndex

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Sun, 18 Jul 2010 18:58:34 -0300, Jim O'Callaghan  
<jc...@yahoo.co.uk> wrote:

> Ideally what I wanted from the grid is an index / ref that survives  
> sorting (though has predictable behavior for additions / deletions) so  
> it can be used for a get(index) on the source list -

In this case, as was suggested before, you probably are best served with a  
custom GridDataSource implementation. Remember that the source parameter  
of Grid isn't List, is GridDataSource, so probably what you're asking  
wouldn't make a lot of sense to be added to Grid itself.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


RE: t:grid, inPlace and rowIndex

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
Thanks Ville, that's very helpful.  I think I'll just stick with my known object ref as the key and do a match on the list through iteration - saves some messing about.  Ideally what I wanted from the grid is an index / ref that survives sorting (though has predictable behavior for additions / deletions) so it can be used for a get(index) on the source list - something like an originalIndex as opposed to a currentDisplayContextIndex - I'm would guess augmenting the model with that would be trivial but I'm aware these are general purpose components and can't really be expected to fit every specific requirement.  In my case the object refs are a compound key, and when passed through an activation context require coercion, and then a check using key.equals(otherKey) per list entry until matched, which is just a few extra cpu cycles I could ideally get rid of.  As you say the cost shouldn't be too much.  The map backed grid seems too much square peg round hole for me.  Thanks for the suggestions all the same.

Regards,
Jim.

-----Original Message-----
From: Ville Virtanen [mailto:ville.virtanen@cerion.fi] 
Sent: 18 July 2010 17:56
To: users@tapestry.apache.org
Subject: RE: t:grid, inPlace and rowIndex


Hi,

you can calculate the exact index of the row by injecting the grid to the
page and calculating it by using methods (getRowsPerPage() x
getCurrentPage()) + index.
(http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/corelib/components/Grid.html)

The index of course changes when you reorder the list. Also, this index
should be updated when doing inPlace update as the index changes depending
in which place you insert the new row.

Should the list that contains the entities be a map instead? (Map<Key,
Entity>) You may have to implement your own GridDataSource that uses the
map, as there is no automatic wrapping for that datatype. (See:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/grid/CollectionGridDataSource.java?revision=964086&view=markup
for reference implementation for collections.)

The cost to iterate the list when doing deletes shouldn't be that much
performance wise - and if you have so many entities that the cost is too
much you should consider implementing special GridDataSource anyway.

 - Ville

jc1001 wrote:
> 
> Hi Thiago,
> 
> I've tried that - but the index is the position within the current 'page'
> of entries in the grid, i.e. zero is the first entry on page one, and also
> on page 2 etc., but also, the inPlace method won't work as the index can't
> be updated because some render phase is skipped.  I guess what I'm looking
> for is some initial index position within the grid (list) entries that is
> not updated during sorting, and so has no need to be updated during an
> inPlace update.
> 
> Regards,
> Jim.
> 
> -----Original Message-----
> From: Thiago H. de Paula Figueiredo [mailto:thiagohp@gmail.com] 
> Sent: 15 July 2010 22:49
> To: Tapestry users
> Subject: Re: t:grid, inPlace and rowIndex
> 
> On Thu, 15 Jul 2010 18:25:03 -0300, Jim O'Callaghan  
> <jc...@yahoo.co.uk> wrote:
> 
>> I'm using the grid to display a selection where one of the cells is an
>> ActionLink that currently passes the entity key for use in a detail  
>> screen> for via the context,
> 
> Have yout tried passing the index as the context for your ActionLink?
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
> and instructor
> Owner, Ars Machina Tecnologia da Informa??o Ltda.
> http://www.arsmachina.com.br
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/t%3Agrid%2C-inPlace-and-rowIndex-tp29177730p29198096.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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



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


RE: t:grid, inPlace and rowIndex

Posted by Ville Virtanen <vi...@cerion.fi>.
Hi,

you can calculate the exact index of the row by injecting the grid to the
page and calculating it by using methods (getRowsPerPage() x
getCurrentPage()) + index.
(http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/corelib/components/Grid.html)

The index of course changes when you reorder the list. Also, this index
should be updated when doing inPlace update as the index changes depending
in which place you insert the new row.

Should the list that contains the entities be a map instead? (Map<Key,
Entity>) You may have to implement your own GridDataSource that uses the
map, as there is no automatic wrapping for that datatype. (See:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/grid/CollectionGridDataSource.java?revision=964086&view=markup
for reference implementation for collections.)

The cost to iterate the list when doing deletes shouldn't be that much
performance wise - and if you have so many entities that the cost is too
much you should consider implementing special GridDataSource anyway.

 - Ville

jc1001 wrote:
> 
> Hi Thiago,
> 
> I've tried that - but the index is the position within the current 'page'
> of entries in the grid, i.e. zero is the first entry on page one, and also
> on page 2 etc., but also, the inPlace method won't work as the index can't
> be updated because some render phase is skipped.  I guess what I'm looking
> for is some initial index position within the grid (list) entries that is
> not updated during sorting, and so has no need to be updated during an
> inPlace update.
> 
> Regards,
> Jim.
> 
> -----Original Message-----
> From: Thiago H. de Paula Figueiredo [mailto:thiagohp@gmail.com] 
> Sent: 15 July 2010 22:49
> To: Tapestry users
> Subject: Re: t:grid, inPlace and rowIndex
> 
> On Thu, 15 Jul 2010 18:25:03 -0300, Jim O'Callaghan  
> <jc...@yahoo.co.uk> wrote:
> 
>> I'm using the grid to display a selection where one of the cells is an
>> ActionLink that currently passes the entity key for use in a detail  
>> screen> for via the context,
> 
> Have yout tried passing the index as the context for your ActionLink?
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
> and instructor
> Owner, Ars Machina Tecnologia da Informa��o Ltda.
> http://www.arsmachina.com.br
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/t%3Agrid%2C-inPlace-and-rowIndex-tp29177730p29198096.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


RE: t:grid, inPlace and rowIndex

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
Hi Thiago,

I've tried that - but the index is the position within the current 'page' of entries in the grid, i.e. zero is the first entry on page one, and also on page 2 etc., but also, the inPlace method won't work as the index can't be updated because some render phase is skipped.  I guess what I'm looking for is some initial index position within the grid (list) entries that is not updated during sorting, and so has no need to be updated during an inPlace update.

Regards,
Jim.

-----Original Message-----
From: Thiago H. de Paula Figueiredo [mailto:thiagohp@gmail.com] 
Sent: 15 July 2010 22:49
To: Tapestry users
Subject: Re: t:grid, inPlace and rowIndex

On Thu, 15 Jul 2010 18:25:03 -0300, Jim O'Callaghan  
<jc...@yahoo.co.uk> wrote:

> I'm using the grid to display a selection where one of the cells is an
> ActionLink that currently passes the entity key for use in a detail  
> screen> for via the context,

Have yout tried passing the index as the context for your ActionLink?

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informa��o Ltda.
http://www.arsmachina.com.br

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



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


Re: t:grid, inPlace and rowIndex

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 15 Jul 2010 18:25:03 -0300, Jim O'Callaghan  
<jc...@yahoo.co.uk> wrote:

> I'm using the grid to display a selection where one of the cells is an
> ActionLink that currently passes the entity key for use in a detail  
> screen> for via the context,

Have yout tried passing the index as the context for your ActionLink?

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


RE: t:grid, inPlace and rowIndex

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
I'm using the grid to display a selection where one of the cells is an
ActionLink that currently passes the entity key for use in a detail screen
for via the context, but I want to be able to pass the entry's list index
instead of the key, to avoid a second iteration through the list (doing a
match on the key equality), ex. To be able to do list.get(n) rather than for
(Iterator iter = list.iterator(); iter.hasnext();){if x.key.equals(y.key)
then ... 

I previously had an index on the persisted object the list contains, but
this is messy for inserts / deletes ...

I can work around it but if there was something built-in it would be handy.

Regards,
Jim.

-----Original Message-----
From: robert zeigler [mailto:robert.zeigler@gmail.com] On Behalf Of Robert
Zeigler
Sent: 15 July 2010 22:12
To: Tapestry users
Subject: Re: t:grid, inPlace and rowIndex

What is it you're trying to accomplish, specifically? Ie, why do you need
the row index when you're not rendering?

Robert

On Jul 15, 2010, at 7/154:07 PM , Jim O'Callaghan wrote:

> Is there an in-built solution for a row index in the t:grid that survives
> sorting and works with inPlace="true" - I'm currently getting the error
> "Component X/Y/Zs is not rendering, so render variable 'rowIndex' may not
be
> updated upon sorting".  I'm trying to get something that tells me the
> current index of the item in a list the grid is displaying, and need the
> index to *not* be updated during sorting.  Is this only possible with a
> representation on the entity the grid is displaying?
> 
> 
> 
> Thanks,
> 
> Jim.
> 


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



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


Re: t:grid, inPlace and rowIndex

Posted by Robert Zeigler <ro...@scazdl.org>.
What is it you're trying to accomplish, specifically? Ie, why do you need the row index when you're not rendering?

Robert

On Jul 15, 2010, at 7/154:07 PM , Jim O'Callaghan wrote:

> Is there an in-built solution for a row index in the t:grid that survives
> sorting and works with inPlace="true" - I'm currently getting the error
> "Component X/Y/Zs is not rendering, so render variable 'rowIndex' may not be
> updated upon sorting".  I'm trying to get something that tells me the
> current index of the item in a list the grid is displaying, and need the
> index to *not* be updated during sorting.  Is this only possible with a
> representation on the entity the grid is displaying?
> 
> 
> 
> Thanks,
> 
> Jim.
> 


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