You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by sean gao <se...@secpay.com> on 2006/01/31 10:24:11 UTC

Re: Tapestry 3 - dynamic event listener problem - F.A.O. Kent Tong


sean gao wrote:
> Thanks Kent,
>  > class YourPageClass {
>  >   void dispatch(IRequestCycle cycle) {
>  >      String listenerName = (String)cycle.getServiceParameters()[0];
>  >      ...
>  >   }
>  > }
> 
> But what do I do after
>   String listenerName = (String)cycle.getServiceParameters()[0];
> Use reflection to invoke the Method that matches the listenerName?
> or the less dynamic,
> if (listenerName.equals("blah"))
>     blah(cycle);
> else if ...
> 
> 
> 
> 
> Kent Tong wrote:
>> sean gao <sean.gao <at> secpay.com> writes:
>>
>>> <div jwcid="links <at> Foreach" source="menuNode" value="menuItem">
>>>       <a jwcid=" <at> DirectLink"    
>>>     listener="ognl:listeners.getListener(menuItem.listenerName)">
>>>           <span jwcid=" <at> Insert"
>>>           value="ognl:getMessage(menuItem.pageName)"/>
>>>       </a>
>>> </div>
>>
>>> It seems that menuItem was "null", but how come menuItem.pageName works? 
>>
>> Because the listener is evaluated in the request handling phase (only 
>> the DirectLink but not the Foreach), while the Insert's value is 
>> evaluated on render.
>>
>>> is this a scope or page rewinding issue? How can I solve it (Tapestry 
>>> 3.03)?
>>
>> Try:
>>
>>  <div jwcid="links <at> Foreach" source="menuNode" value="menuItem">
>>        <a jwcid=" <at> DirectLink"    
>>      listener="ognl:listeners.dispatch"
>>      parameters="ognl:menuItem.listenerName">
>>            <span jwcid=" <at> Insert"
>>            value="ognl:getMessage(menuItem.pageName)"/>
>>        </a>
>>  </div>
>>
>> class YourPageClass {
>>   void dispatch(IRequestCycle cycle) {
>>      String listenerName = (String)cycle.getServiceParameters()[0];
>>      ...
>>   }
>> }
>>
>> -- 
>> Author of a book for learning Tapestry (http://www.agileskills2.org/EWDT)
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org