On Fri, 18 Feb 2011 15:22:28 -0200, Erik Fäßler <erik.faess...@uni-jena.de> wrote:

  Thank you for your answer!

It isn't gone. Now you have a single EventLink which is rendered once for each Loop iteration. Static structure, dynamic behavior. ;)
So when I have several components of the same type in my .tml it does a difference to having a loop?

If the component is inside a Loop, yes.

I thought it's just a different way to say the same thing.

It's very, very, very different in Tapestry.

One EventLink instance, regardless of how many iterations:
<li t:type="Loop">
        <a t:type="EventLink">...</a>
</li>

Three EventLink instances:
<a t:type="EventLink">...</a>
<a t:type="EventLink">...</a>
<a t:type="EventLink">...</a>

Use the context parameter of EventLink to identify each rendered link.
Hm, I thought about that. But how does it help me to know which component should have been triggered when its still the wrong one?

That's what t:id is for. Anyway, it's better to pass the needed information in the context instead of relying on which component instance triggered the event. This is particularly true when your component is inside a loop of any kind (Loop, AjaxFormLoop, Grid, etc).

Could you please explain how the context parameter would help me? Thank you for your help :)

It would be way easier to explain if you posted your component and what it's supposed to do.

One example: suppose you have a list of objects and you want to provide a link to delete:

<li t:type="Loop" t:source="objects" t:row="object">
        ....
        <a t:type="EventLink" t:event="delete" t:context="object.id">Delete</a>
</li>

void onDelete(Integer id) {
        SomeClass object = // get original object from its id
        // process object.
}

--
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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to