You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by karthi <ra...@snovabits.net> on 2012/03/12 11:53:32 UTC

Is there any way to get the selected item's index in loop after layout has been done?

Hi,

In the java page I have,

    @Property
    private int currentIndex;

    public List<VideoItem> getVideoDatas() {
		videoItems = null;
		VideoItemCollection collection = new
VideoItemCollection(Constants.VIDEOS);
		if(collection.videoItems.size() > 0) {
			videoItems = collection.videoItems;
		}
		return videoItems;
	}

In the .tml page,

<t:loop source="videoDatas" encoder="encoder" value="videoItem"
index="currentIndex">
---
--- body ---
---
</t:loop>


The video datas size is 35.

Now after all the layout has been done by jvm or something for this page,
when the user clicks on an item which is inside that loop i.e., one of the
35 items for eg., 5th item, how to retrieve that particular item's index in
that corresponding java page..

When I print this currentIndex it shows 35...

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Is-there-any-way-to-get-the-selected-item-s-index-in-loop-after-layout-has-been-done-tp5557270p5557270.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: Is there any way to get the selected item's index in loop after layout has been done?

Posted by karthi <ra...@snovabits.net>.
No in that loop examples they are getting the loop source values and passed
to other pages, I've used that 

using the currentIndex in that same java page,

public String getAlternateColour() {
		String bgColor = null;
		if(currentIndex%2 == 0) {
			bgColor = "#EBEBEB";
		} else {
			bgColor = "#CBCBCB";
		}
		return bgColor;
	} 

also in .tml page inside loop,

<t:loop source="videoDatas" encoder="encoder" value="videoItem"
index="currentIndex">
<table width="100%" cellpadding="2" cellspacing="0">
<tr style="background-color: ${alternateColour}">
<td>
<p class="text">${videoItem.name}</p>
<br />
<input class="button_style_left" t:type="submit" value="Info" t:id="info" />
</td>
</tr>
</table>
</t:loop>

This loop contains 35 items - name and a button with alternate background
color and for eg., if the user clicked on the 7th item button then I want
that index in that corresponding java page?

When 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Is-there-any-way-to-get-the-selected-item-s-index-in-loop-after-layout-has-been-done-tp5557270p5557467.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: Is there any way to get the selected item's index in loop after layout has been done?

Posted by Chris Mylonas <ch...@opencsta.org>.

Something like this http://jumpstart.doublenegative.com.au/jumpstart/examples/tables/linkingloop1
If not that one, there are other examples: http://jumpstart.doublenegative.com.au/jumpstart/examples
You'll find your answer there


On 12/03/2012, at 9:53 PM, karthi wrote:

> Hi,
> 
> In the java page I have,
> 
>    @Property
>    private int currentIndex;
> 
>    public List<VideoItem> getVideoDatas() {
> 		videoItems = null;
> 		VideoItemCollection collection = new
> VideoItemCollection(Constants.VIDEOS);
> 		if(collection.videoItems.size() > 0) {
> 			videoItems = collection.videoItems;
> 		}
> 		return videoItems;
> 	}
> 
> In the .tml page,
> 
> <t:loop source="videoDatas" encoder="encoder" value="videoItem"
> index="currentIndex">
> ---
> --- body ---
> ---
> </t:loop>
> 
> 
> The video datas size is 35.
> 
> Now after all the layout has been done by jvm or something for this page,
> when the user clicks on an item which is inside that loop i.e., one of the
> 35 items for eg., 5th item, how to retrieve that particular item's index in
> that corresponding java page..
> 
> When I print this currentIndex it shows 35...
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Is-there-any-way-to-get-the-selected-item-s-index-in-loop-after-layout-has-been-done-tp5557270p5557270.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: Is there any way to get the selected item's index in loop after layout has been done?

Posted by Lance Java <la...@googlemail.com>.
I'm not sure why you would want to pass an index around... surely an id is
better?

eg
<t:loop source="videoDatas" value="videoItem">
   <t:pagelink page="someOtherPage" t:context="videoItem.videoId" />
</t:loop>


If you NEED to pass the index (I strongly advise against this, what happens
if you decide to let the user sort the list) then you could do the
following:

<t:loop source="videoDatas" value="videoItem" index="currentIndex">
   <t:pagelink page="someOtherPage" t:context="currentIndex" />
</t:loop>

As suggested in this thread, I think that this example is what you want
http://jumpstart.doublenegative.com.au/jumpstart/examples/tables/linkingloop1

On Wednesday, 14 March 2012, karthi <ra...@snovabits.net> wrote:
> I've seen your answer, Thank you very much for continuously helping me...
Was
> looking for some tapestry code or a trick...
>
> Atlast one of my friends suggest me to add a property called position in
> pojo class & set the value of the index to that when setting values for
> other items & in tml page inside the loop in the action link asked me to
add
> t:context="musicItem.pos" and get this value as a paramater in java class.
> This works great!!
>
>
>
> --
> View this message in context:
http://tapestry.1045711.n5.nabble.com/Is-there-any-way-to-get-the-selected-item-s-index-in-loop-after-layout-has-been-done-tp5557270p5563662.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: Is there any way to get the selected item's index in loop after layout has been done?

Posted by karthi <ra...@snovabits.net>.
I've seen your answer, Thank you very much for continuously helping me... Was
looking for some tapestry code or a trick...

Atlast one of my friends suggest me to add a property called position in
pojo class & set the value of the index to that when setting values for
other items & in tml page inside the loop in the action link asked me to add
t:context="musicItem.pos" and get this value as a paramater in java class.
This works great!!



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Is-there-any-way-to-get-the-selected-item-s-index-in-loop-after-layout-has-been-done-tp5557270p5563662.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: Is there any way to get the selected item's index in loop after layout has been done?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 13 Mar 2012 08:28:18 -0300, karthi <ra...@snovabits.net>  
wrote:

> Anyone help me? Can't able to do that

Have you seen my answer? Basically, if you want to read something after  
the HTML is rendered, you need to store this something in HTML or  
JavaScript in some way. I've already suggested one easy way of doing it.

-- 
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: Is there any way to get the selected item's index in loop after layout has been done?

Posted by karthi <ra...@snovabits.net>.
Anyone help me? Can't able to do that

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Is-there-any-way-to-get-the-selected-item-s-index-in-loop-after-layout-has-been-done-tp5557270p5560679.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: Is there any way to get the selected item's index in loop after layout has been done?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Put the index in some attribute (rel is a good one for this) and retrive  
the value of it in JavaScript when something is selected.

-- 
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