Ah ok..scratch my last reply :) 

On 8/30/05, Jesse Kuhnert <[EMAIL PROTECTED]> wrote:
> 
> I could be wrong, but I think the For component does some special logic 
> when doing loops, like the case where it is looping over things in the form. 
> It should magically resolve the "current" object you are referencing when 
> the form is submitted. 
> 
> Foreach does not do any of this special magic, so when your listener is 
> invoked, there is no concept of a "current" object, as it was a direct 
> invocation. 
> 
> Doesn't the For component work just as well in or outside of a Form? 
> 
> On 8/30/05, Denis Souza <[EMAIL PROTECTED]> wrote:
> > 
> > Consider this example:
> > 
> > 
> > 
> > In my html template:
> > 
> > 
> > 
> > .
> > 
> > 
> > 
> > <table>
> > 
> > .
> > 
> > <tr jwcid="@Foreach" element="tr" source="ognl:myList"
> > value="ognl:listItem"> 
> > 
> > <td> . </td>
> > 
> > <td><input type="submit" jwcid="@Submit"
> > listener="listener:removeItem" label="message:remove"/></td> 
> > 
> > </tr>
> > 
> > </table>
> > 
> > .
> > 
> > 
> > 
> > In my java class I have a listener:
> > 
> > 
> > 
> > public void removeItem() {
> > 
> > getMyList().remove (getlistItem());
> > 
> > }
> > 
> > 
> > 
> > 
> > 
> > So, to put it in English, I have a Foreach loop with a listener inside 
> > it
> > that is supposed to remove an item from the list being displayed.
> > 
> > Whenever I click one of the "remove" buttons my removeItem() method is 
> > called as it should, except that the item returned by "getListItem()" is
> > always the last item in the list. It's never the item corresponding to 
> > the
> > removed button I clicked, so I always end up removing the last item, no 
> > matter which button I click on.
> > 
> > When I use "For" instead of "Foreach" not only does the "getListItem()"
> > contain the last item in the list, but the list is intact when the page 
> > is 
> > reloaded (no items removed).
> > 
> > 
> > 
> > To me this seems very strange since there is no other way of knowing 
> > which
> > of the buttons was clicked. I don't know if I'm doing something wrong or 
> > if
> > it's a bug. I understand that doing this was an issue in Tapestry 3 due 
> > to 
> > limitations during the rewind cycle and I had to use some special logic 
> > to
> > do it. I thought in Tapestry 4 I could use this more direct approach but
> > maybe I'm still missing something.
> > 
> > 
> > 
> > I'm using Tapestry4-beta5 but I tried it with beta4 and got the same 
> > problem.
> > 
> > 
> > 
> > Any ideas?
> > 
> > 
> > 
> > Thanks
> > 
> > Denis Souza
> > 
> > 
> > 
> > 
> > 
>

Reply via email to