it is doable with components -
the idea is that on rewind, each iteration can store the current data in a
'global' structure which your listener will then work on

On Thu, Feb 28, 2008 at 4:33 PM, Petri Wessman <[EMAIL PROTECTED]> wrote:
> Andreas Andreou wrote:
>  > Why do you need to "iterate through the components thing in the listener"?
>  > Can you explain what you're after?
>
>  Maybe I wasn't clear enough. What I want to do is to edit 1-N identical
>  records on one page. I currently have a component which encapsulates the
>  editing of fields of one record, with input fields and properties into
>  which the values get stored.
>
>  When the submit button on the page is pressed, I expect the data for
>  each record to get stored into the corresponding component. Then in the
>  listener method, I would need to fetch the values from the components,
>  so I could do a batch update into the database.
>
>  Of course, that may not work in the first place, given Tapestry's
>  architecture.
>
>
>  > BTW, there's only one FoobarEdit instance, so, that's why you get one!
>
>  Hmmm. My expectation is that the For loop would create one instance per
>  loop iteration... are you saying it doesn't?
>
>  That would explain why my plan is doomed to failure, of course :}
>
>  Ok, given the above, am I to understand that what I was trying to do
>  isn't doable with components? That I should just get rid of the
>  component and just have the input fields inside the For loop?
>
>  That's doable, but results in some regrettable copy-paste since I need
>  to do this edit thing on more than one page -- that's why I went the
>  component route in the first place :/.
>
>  //Petri
>
>
>
>  >
>  > 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]
>  >>
>  >>
>  >
>  >
>  >
>
>
>  ---------------------------------------------------------------------
>  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]

Reply via email to