hi pierce,

don't you have the same problem if you 
put 10 eventlinks on your page. how do you
distinguish them? either you have 10 different
event links onEventFromC1() or you use the
context onEvent(String id)... or onEvent(AlmostAnyObject obj)
having a loop rendering the 10 eventlinks is
more or less the same.

if your component creates an eventlink
it should also be able to handle it and
therefore provide the corresponding event
handler. 

g,
kris



Von:    "Pierce T. Wetter III" <pie...@paceap.com>
An:     "Tapestry users" <users@tapestry.apache.org>
Datum:  07.04.2010 14:35
Betreff:        Re: Suggestion: Add context to loop




>>    As a new user of tapestry, loop actually bit me because I assumed it 
did this already and was surprised in my event handlers when my value 
binding was null.
>>      <a class="fancy" t:type="eventlink" event="select"><t:body /></a>
> 
> Why not passing the current object as the context of the EventLink 
instead?
> 
> <a class="fancy" t:type="eventlink" event="select" 
t:context="value.id"><t:body /></a>
> 
> public Object onSelect(IdType id) {
>                ...
>> }

   1. What if the eventlink is nested several layers deep in components? 
Then value has to be passed all the way down...

   2. Now the nested component needs to know about how the value object is 
encoded, which makes the nested component less "generic" and therefore 
less reusable. In my sample, nestedcomponent doesn't know anything at all 
about "value". It doesn't need to! It's job is just to generate a "fancy" 
link. Instead, that knowledge is localized to where loop is used, which 
also happens to be where the event is processed. 

  Pierce

 

 
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


Reply via email to