Re: Get component id in EventListener with multiple targets
Just add a BrowserEvent parameter to your method and it will be automatically populated for you. Once added you should be able to do something along the lines of this to figure out which component fired the event (maybe I should enhance this part to provide a more direct route): void someButtonClicked(IRequestCycle cycle, BrowserEvent event) { String componentClientId = (String)event.getTarget().get(id); } On 12/20/06, Peter Beshai [EMAIL PROTECTED] wrote: I would like to have multiple targets hooked into a single EventListener, but I cannot figure out how to distinguish which component fired the event within the listener itself. For example, if I have an event listener: @EventListener(targets = {button1,button2,button3,button4}, events= onclick) *public* *void* someButtonClicked(IRequestCycle cycle) { ... } and I need to pass the id of the component that fired off the event listener to another function within the listener. Is there anyway to do this without having to give each button an event listener and having those event listeners all call another function with the component's ID as an argument? -- Peter Beshai - Using Tapestry 4.1.1 Pure Mathematics Student University of Waterloo -- Jesse Kuhnert Tapestry/Dojo team member/developer Open source based consulting work centered around dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Get component id in EventListener with multiple targets
Jesse Kuhnert a écrit : Just add a BrowserEvent parameter to your method and it will be automatically populated for you. Once added you should be able to do something along the lines of this to figure out which component fired the event (maybe I should enhance this part to provide a more direct route): void someButtonClicked(IRequestCycle cycle, BrowserEvent event) { String componentClientId = (String)event.getTarget().get(id); } Just to say that it is a pleasure to read the Tapestry mailing list. When a problem is showed, shure in some time later a nice Tapestry solution is given. Tapestry looks like a really great WebApp Framework. Cyrille On 12/20/06, Peter Beshai [EMAIL PROTECTED] wrote: I would like to have multiple targets hooked into a single EventListener, but I cannot figure out how to distinguish which component fired the event within the listener itself. For example, if I have an event listener: @EventListener(targets = {button1,button2,button3,button4}, events= onclick) *public* *void* someButtonClicked(IRequestCycle cycle) { ... } and I need to pass the id of the component that fired off the event listener to another function within the listener. Is there anyway to do this without having to give each button an event listener and having those event listeners all call another function with the component's ID as an argument? -- Peter Beshai - Using Tapestry 4.1.1 Pure Mathematics Student University of Waterloo - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]