You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kris Rasmussen <kr...@yahoo.com> on 2004/04/07 08:31:21 UTC

Problem with multiple instances of same component...

I have a page which has a for loop that creates many instances of a single component. This component allows the user to enter a value into a text field and then click add (one add button per component). The problem is that all instances of the component seem to share the same property where the value of the user input is stored. I would like to think that tapestry would maintain seperate properties for each component instance but I guess it does not? So for this component I guess I will have to implement it such that it stores data in a different location depending on a parameter or the like?
 
Thanks 


---------------------------------
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway - Enter today

Re: Problem with multiple instances of same component...

Posted by Robert Zeigler <rd...@u.arizona.edu>.
You could try something like:

<property-specification name="myValue" type="java.lang.String[]"/>
<property-specification name="index" type="int"/>
<property-specification name="source" type="java.util.List" 
persistent="yes"/>
<property-specification name="currentValue" type="java.lang.String"/>
<component id="someLoop" type="Foreach">
 <binding name="index" expression="index"/>
 <binding name="source" expression="source"/>
 <binding name="value" expression="currentValue"/>
</component>
<component id="field" type="TextField">
  <binding name="value" expression="myValue[index]"/>
</component>

Just be sure to implement PageRenderListener and property initialize 
"myValue" in
pageBeginRender.

I actually just encountered a very similar situation tonight,
where I had numerous (determined at runtime) multiple-select boxes 
inside a foreach; this approach worked for me.
(Though I would love to see how more experienced tapestry users handle 
something like this. =)

Robert

Kris Rasmussen wrote:

>I have a page which has a for loop that creates many instances of a single component. This component allows the user to enter a value into a text field and then click add (one add button per component). The problem is that all instances of the component seem to share the same property where the value of the user input is stored. I would like to think that tapestry would maintain seperate properties for each component instance but I guess it does not? So for this component I guess I will have to implement it such that it stores data in a different location depending on a parameter or the like?
> 
>Thanks 
>
>
>---------------------------------
>Do you Yahoo!?
>Yahoo! Small Business $15K Web Design Giveaway - Enter today
>  
>


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


Re: Problem with multiple instances of same component...

Posted by Jamie Orchard-Hays <ja...@dang.com>.
Have a look at ListEdit component. This might be what you're after.

Jamie
----- Original Message ----- 
From: "Kris Rasmussen" <kr...@yahoo.com>
To: <ta...@jakarta.apache.org>
Sent: Wednesday, April 07, 2004 2:31 AM
Subject: Problem with multiple instances of same component...


> I have a page which has a for loop that creates many instances of a single
component. This component allows the user to enter a value into a text field
and then click add (one add button per component). The problem is that all
instances of the component seem to share the same property where the value
of the user input is stored. I would like to think that tapestry would
maintain seperate properties for each component instance but I guess it does
not? So for this component I guess I will have to implement it such that it
stores data in a different location depending on a parameter or the like?
>
> Thanks
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Small Business $15K Web Design Giveaway - Enter today


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