Why do you need to "iterate through the components thing in the listener"? Can you explain what you're after?
BTW, there's only one FoobarEdit instance, so, that's why you get one! On Thu, Feb 28, 2008 at 3:32 PM, Petri Wessman <[EMAIL PROTECTED]> wrote: > Ok, I'm a bit stumped here. I'm using Tapestry 4.1.3, and I'm trying to > use (sub)components which have form input fields inside a For loop. > > I have a list of items, initialized by a "calling" page, and one as > placeholder for the current value, something like this: > > public abstract Foobar getCurrentFoobar(); > > @Persist > public abstract List<Foo> getFoobars(); > public abstract void setFoobars(List<Foobar> value); > > > The template has code like this: > > <form jwcid="@Form"> > > <div jwcid="@For" source="ognl:foobars" value="ognl:currentFoobar"> > <div jwcid="@FoobarEdit" foobar="ognl:currentFoobar"/> > </div> > > <input type="submit" jwcid="@Submit" > action="listener:dostuff"/> > > </form> > > The FoobarEdit component contains edit fields for various attributes of > the Foobar object. When submit is pressed on the page, I want to iterate > through the components and use them to do a batch-edit of multiple > Foobar values into the database. > > Now, things work fine at display time, I get a nice list of edit > components, with input fields. > > The problem comes when I want to do the "iterate through the components" > thing in the listener. I found the method getComponents() in > AbstractComponent, which should return a Map of the components > containted on this page/component, keyed by id. > > However, when I call that, I only get *one* of the FoobarEdit > components, with a key $FoobarEdit. The other unnamed components on the > page get ids like $If_0, $If_1 to separate them from each other, but not > my own component. > > Either only one component exists internally when the listener is called > (for some weird reason), or they are all getting the $FoobarEdit id > instead of a numbered one, making all but one of them invisible in the > component map. > > So... I'm stumped. What am I doing wrong, and/or how should I best do > this? Is there some way to manually specify the id of the generated > component in some dynamic fashion? Should I iterate through the > components via some other fashion? Is this whole idea of doing batch > processing of multiple elements via subcomponents like this simply not > doable in Tapestry? > > Any help much appreciated. > > //Petri > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr Tapestry / Tacos developer Open Source / JEE Consulting --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]