You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Christian Dutaret <cd...@gmail.com> on 2006/10/03 15:16:25 UTC

EventListener on components within a @For loop

Hi,

Is it possible to have an EventListener for events on components within a
@For loop? Typically, I have a set of radio buttons, which are rendered from
@Radio components within a @For loop (with a surrounding @RadioGroup
component), and I want to invoke a listener whenever an onclick event occurs
on any of those radio buttons.
I could achieve this with @contrib:XTile components, but I'd rather use the
same programming model everywhere. It would be nice, for instance, to set an
EvenListener on the @RadioGroup component, and have it propagate the event
on nested @Radio components.

Thx
Ch.

Re: EventListener on components within a @For loop

Posted by Julian Wood <wo...@ucalgary.ca>.
https://issues.apache.org/jira/browse/TAPESTRY-1405

In the meantime I'll use Christian's approach.

Thanks, J

On 5-Apr-07, at 11:19 AM, Julian Wood wrote:

> Was this ever dealt with? Attaching an event  listener to a radio  
> group component still doesn't work for me in the latest 4.1.2  
> snapshot, though if i change it to a property selection, it does. I  
> couldn't find a JIRA issue which looked like it dealt with this  
> specifically - maybe http://issues.apache.org/jira/browse/ 
> TAPESTRY-1039 but it is not a very comprehensive report and while  
> the title loosely matches this issue, the description seems to hint  
> at something else.
>
> J
>
> On 4-Oct-06, at 12:59 PM, Jesse Kuhnert wrote:
>
>> Hah! That's pretty cool. I like it :)
>>
>> If someone files a bug in JIRA I'll look into the radio button stuff
>> .(though I thought I remembered there being a ticket for this  
>> already - at
>> least I know we had to deal with it in tacos )
>>
>> On 10/4/06, Christian Dutaret <cd...@gmail.com> wrote:
>>>
>>> I found a nice solution using dojo's ability to listen to an  
>>> arbitrary
>>> javascript function as if it were a native event.
>>> I attach an empty js function to an arbitrary DOM element like this:
>>>
>>> document.getElementById('someDiv').clickRadio=function(radio) {};
>>>
>>> and an onclick attribute to my radio buttons:
>>>
>>> <span jwcid="@Radio" value="ognl:lv.value" onclick="
>>> document.getElementById
>>> ('someDiv').clickRadio(this);"/>
>>>
>>> Then I can set an EventListener on the server-side
>>>
>>>     @EventListener(targets = "someDiv", events = "clickRadio",  
>>> submitForm
>>> =
>>> "form")
>>>     public void listenToOnclickOnAnyRadioButtonInTheForLoop 
>>> (IRequestCycle
>>> cycle) throws InterruptedException {
>>>         ...
>>>     }
>>>
>>> Works fine.
>>> Ch.
>>>
>>>
>>> 2006/10/3, Dennis Sinelnikov <de...@augustschell.com>:
>>> >
>>> > I'm glad someone else has a need for this as well.  From doing  
>>> a little
>>> > bit of research the other day, I found @EventListener  
>>> annotation that
>>> > was introduced into tapestry 4.1+ that "sort of" fixes the  
>>> problem. I'm
>>> > currently using stable release of tapestry 4.0.2, so I didn't  
>>> bother
>>> > going that route. I believe this can be accomplished with  
>>> tacos, but not
>>> > sure.  If you find something I would love to see an example,  
>>> I'll do the
>>> > same as well...
>>> >
>>> > Good Luck,
>>> > Dennis
>>> >
>>> > Christian Dutaret wrote:
>>> > > Hi,
>>> > >
>>> > > Is it possible to have an EventListener for events on components
>>> within
>>> > a
>>> > > @For loop? Typically, I have a set of radio buttons, which are
>>> rendered
>>> > > from
>>> > > @Radio components within a @For loop (with a surrounding  
>>> @RadioGroup
>>> > > component), and I want to invoke a listener whenever an  
>>> onclick event
>>> > > occurs
>>> > > on any of those radio buttons.
>>> > > I could achieve this with @contrib:XTile components, but I'd  
>>> rather
>>> use
>>> > the
>>> > > same programming model everywhere. It would be nice, for  
>>> instance, to
>>> > > set an
>>> > > EvenListener on the @RadioGroup component, and have it  
>>> propagate the
>>> > event
>>> > > on nested @Radio components.
>>> > >
>>> > > Thx
>>> > > Ch.
>>> > >
>
> --
> Julian Wood <wo...@ucalgary.ca>
>
> Software Engineer
> Teaching & Learning Centre
> University of Calgary
>
> http://tlc.ucalgary.ca
>
>

--
Julian Wood <wo...@ucalgary.ca>

Software Engineer
Teaching & Learning Centre
University of Calgary

http://tlc.ucalgary.ca



Re: EventListener on components within a @For loop

Posted by Julian Wood <wo...@ucalgary.ca>.
Was this ever dealt with? Attaching an event  listener to a radio  
group component still doesn't work for me in the latest 4.1.2  
snapshot, though if i change it to a property selection, it does. I  
couldn't find a JIRA issue which looked like it dealt with this  
specifically - maybe http://issues.apache.org/jira/browse/ 
TAPESTRY-1039 but it is not a very comprehensive report and while the  
title loosely matches this issue, the description seems to hint at  
something else.

J

On 4-Oct-06, at 12:59 PM, Jesse Kuhnert wrote:

> Hah! That's pretty cool. I like it :)
>
> If someone files a bug in JIRA I'll look into the radio button stuff
> .(though I thought I remembered there being a ticket for this  
> already - at
> least I know we had to deal with it in tacos )
>
> On 10/4/06, Christian Dutaret <cd...@gmail.com> wrote:
>>
>> I found a nice solution using dojo's ability to listen to an  
>> arbitrary
>> javascript function as if it were a native event.
>> I attach an empty js function to an arbitrary DOM element like this:
>>
>> document.getElementById('someDiv').clickRadio=function(radio) {};
>>
>> and an onclick attribute to my radio buttons:
>>
>> <span jwcid="@Radio" value="ognl:lv.value" onclick="
>> document.getElementById
>> ('someDiv').clickRadio(this);"/>
>>
>> Then I can set an EventListener on the server-side
>>
>>     @EventListener(targets = "someDiv", events = "clickRadio",  
>> submitForm
>> =
>> "form")
>>     public void listenToOnclickOnAnyRadioButtonInTheForLoop 
>> (IRequestCycle
>> cycle) throws InterruptedException {
>>         ...
>>     }
>>
>> Works fine.
>> Ch.
>>
>>
>> 2006/10/3, Dennis Sinelnikov <de...@augustschell.com>:
>> >
>> > I'm glad someone else has a need for this as well.  From doing a  
>> little
>> > bit of research the other day, I found @EventListener annotation  
>> that
>> > was introduced into tapestry 4.1+ that "sort of" fixes the  
>> problem. I'm
>> > currently using stable release of tapestry 4.0.2, so I didn't  
>> bother
>> > going that route. I believe this can be accomplished with tacos,  
>> but not
>> > sure.  If you find something I would love to see an example,  
>> I'll do the
>> > same as well...
>> >
>> > Good Luck,
>> > Dennis
>> >
>> > Christian Dutaret wrote:
>> > > Hi,
>> > >
>> > > Is it possible to have an EventListener for events on components
>> within
>> > a
>> > > @For loop? Typically, I have a set of radio buttons, which are
>> rendered
>> > > from
>> > > @Radio components within a @For loop (with a surrounding  
>> @RadioGroup
>> > > component), and I want to invoke a listener whenever an  
>> onclick event
>> > > occurs
>> > > on any of those radio buttons.
>> > > I could achieve this with @contrib:XTile components, but I'd  
>> rather
>> use
>> > the
>> > > same programming model everywhere. It would be nice, for  
>> instance, to
>> > > set an
>> > > EvenListener on the @RadioGroup component, and have it  
>> propagate the
>> > event
>> > > on nested @Radio components.
>> > >
>> > > Thx
>> > > Ch.
>> > >

--
Julian Wood <wo...@ucalgary.ca>

Software Engineer
Teaching & Learning Centre
University of Calgary

http://tlc.ucalgary.ca



Re: EventListener on components within a @For loop

Posted by Patrick Moore <tr...@gmail.com>.
https://issues.apache.org/jira/browse/TAPESTRY-1132

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


Re: EventListener on components within a @For loop

Posted by Jesse Kuhnert <jk...@gmail.com>.
Ohh,....Right, parameters . I don't know if a JIRA issue is opened for it
(support parameters using @EventListener, somehow..) , but that would be a
good start towards getting that resolved.

On 10/27/06, Patrick Moore <tr...@gmail.com> wrote:
>
> What I am hoping to do is something like this:
>
> <span jwcid="@For" value="ognl:current">
>      <a jwcid="foo"><span jwcid="@Insert" value="ognl:current"/></a>
>      <span jwcid="@InvokeListener" listener="listener:makeLink"/>
> </span>
>
> and code like this:
>
>    public void makeLink() {
>        IEventListener listener = getFoo().getEventListener("onclick");
>        listener.setEventHandler("bar");
>        listener.setParameters(new Object[]{ getCurrent().getEntityId()});
>    }
>
>    // called when user clicks on one of the generated links in @For
>    public void bar(Long entityId) {
>       System.out.println("link for "+ entityId +"was clicked!");
>    }
>
> Hope that helps...
>
> -Pat
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo/(and a dash of TestNG), team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

Re: EventListener on components within a @For loop

Posted by Patrick Moore <tr...@gmail.com>.
What I am hoping to do is something like this:

<span jwcid="@For" value="ognl:current">
     <a jwcid="foo"><span jwcid="@Insert" value="ognl:current"/></a>
     <span jwcid="@InvokeListener" listener="listener:makeLink"/>
</span>

and code like this:

   public void makeLink() {
       IEventListener listener = getFoo().getEventListener("onclick");
       listener.setEventHandler("bar");
       listener.setParameters(new Object[]{ getCurrent().getEntityId()});
   }

   // called when user clicks on one of the generated links in @For
   public void bar(Long entityId) {
      System.out.println("link for "+ entityId +"was clicked!");
   }

Hope that helps...

-Pat

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


Re: EventListener on components within a @For loop

Posted by Jesse Kuhnert <jk...@gmail.com>.
I'm not sure I understand what you mean. What model do you think would feel
more natural?

On 10/25/06, Patrick Moore <tr...@gmail.com> wrote:
>
> Is there any more on this?
>
> I am just now starting to explore the EventListener model. I must
> admit I find it a little odd that I can't wire things up
> programatically. It feels wrong that I need to decide at compile time
> that two components are talking to each other.
>
> Or is there something new?
>
> -Pat
>
> On 10/4/06, Jesse Kuhnert <jk...@gmail.com> wrote:
> > Hah! That's pretty cool. I like it :)
> >
> > If someone files a bug in JIRA I'll look into the radio button stuff
> > .(though I thought I remembered there being a ticket for this already -
> at
> > least I know we had to deal with it in tacos )
> >
> > On 10/4/06, Christian Dutaret <cd...@gmail.com> wrote:
> > >
> > > I found a nice solution using dojo's ability to listen to an arbitrary
> > > javascript function as if it were a native event.
> > > I attach an empty js function to an arbitrary DOM element like this:
> > >
> > > document.getElementById('someDiv').clickRadio=function(radio) {};
> > >
> > > and an onclick attribute to my radio buttons:
> > >
> > > <span jwcid="@Radio" value="ognl:lv.value" onclick="
> > > document.getElementById
> > > ('someDiv').clickRadio(this);"/>
> > >
> > > Then I can set an EventListener on the server-side
> > >
> > >     @EventListener(targets = "someDiv", events = "clickRadio",
> submitForm
> > > =
> > > "form")
> > >     public void
> listenToOnclickOnAnyRadioButtonInTheForLoop(IRequestCycle
> > > cycle) throws InterruptedException {
> > >         ...
> > >     }
> > >
> > > Works fine.
> > > Ch.
> > >
> > >
> > > 2006/10/3, Dennis Sinelnikov <de...@augustschell.com>:
> > > >
> > > > I'm glad someone else has a need for this as well.  From doing a
> little
> > > > bit of research the other day, I found @EventListener annotation
> that
> > > > was introduced into tapestry 4.1+ that "sort of" fixes the problem.
> I'm
> > > > currently using stable release of tapestry 4.0.2, so I didn't bother
> > > > going that route. I believe this can be accomplished with tacos, but
> not
> > > > sure.  If you find something I would love to see an example, I'll do
> the
> > > > same as well...
> > > >
> > > > Good Luck,
> > > > Dennis
> > > >
> > > > Christian Dutaret wrote:
> > > > > Hi,
> > > > >
> > > > > Is it possible to have an EventListener for events on components
> > > within
> > > > a
> > > > > @For loop? Typically, I have a set of radio buttons, which are
> > > rendered
> > > > > from
> > > > > @Radio components within a @For loop (with a surrounding
> @RadioGroup
> > > > > component), and I want to invoke a listener whenever an onclick
> event
> > > > > occurs
> > > > > on any of those radio buttons.
> > > > > I could achieve this with @contrib:XTile components, but I'd
> rather
> > > use
> > > > the
> > > > > same programming model everywhere. It would be nice, for instance,
> to
> > > > > set an
> > > > > EvenListener on the @RadioGroup component, and have it propagate
> the
> > > > event
> > > > > on nested @Radio components.
> > > > >
> > > > > Thx
> > > > > Ch.
> > > > >
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> > >
> > >
> >
> >
> > --
> > Jesse Kuhnert
> > Tapestry/Dojo/(and a dash of TestNG), team member/developer
> >
> > Open source based consulting work centered around
> > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo/(and a dash of TestNG), team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

Re: EventListener on components within a @For loop

Posted by Patrick Moore <tr...@gmail.com>.
Is there any more on this?

I am just now starting to explore the EventListener model. I must
admit I find it a little odd that I can't wire things up
programatically. It feels wrong that I need to decide at compile time
that two components are talking to each other.

Or is there something new?

-Pat

On 10/4/06, Jesse Kuhnert <jk...@gmail.com> wrote:
> Hah! That's pretty cool. I like it :)
>
> If someone files a bug in JIRA I'll look into the radio button stuff
> .(though I thought I remembered there being a ticket for this already - at
> least I know we had to deal with it in tacos )
>
> On 10/4/06, Christian Dutaret <cd...@gmail.com> wrote:
> >
> > I found a nice solution using dojo's ability to listen to an arbitrary
> > javascript function as if it were a native event.
> > I attach an empty js function to an arbitrary DOM element like this:
> >
> > document.getElementById('someDiv').clickRadio=function(radio) {};
> >
> > and an onclick attribute to my radio buttons:
> >
> > <span jwcid="@Radio" value="ognl:lv.value" onclick="
> > document.getElementById
> > ('someDiv').clickRadio(this);"/>
> >
> > Then I can set an EventListener on the server-side
> >
> >     @EventListener(targets = "someDiv", events = "clickRadio", submitForm
> > =
> > "form")
> >     public void listenToOnclickOnAnyRadioButtonInTheForLoop(IRequestCycle
> > cycle) throws InterruptedException {
> >         ...
> >     }
> >
> > Works fine.
> > Ch.
> >
> >
> > 2006/10/3, Dennis Sinelnikov <de...@augustschell.com>:
> > >
> > > I'm glad someone else has a need for this as well.  From doing a little
> > > bit of research the other day, I found @EventListener annotation that
> > > was introduced into tapestry 4.1+ that "sort of" fixes the problem. I'm
> > > currently using stable release of tapestry 4.0.2, so I didn't bother
> > > going that route. I believe this can be accomplished with tacos, but not
> > > sure.  If you find something I would love to see an example, I'll do the
> > > same as well...
> > >
> > > Good Luck,
> > > Dennis
> > >
> > > Christian Dutaret wrote:
> > > > Hi,
> > > >
> > > > Is it possible to have an EventListener for events on components
> > within
> > > a
> > > > @For loop? Typically, I have a set of radio buttons, which are
> > rendered
> > > > from
> > > > @Radio components within a @For loop (with a surrounding @RadioGroup
> > > > component), and I want to invoke a listener whenever an onclick event
> > > > occurs
> > > > on any of those radio buttons.
> > > > I could achieve this with @contrib:XTile components, but I'd rather
> > use
> > > the
> > > > same programming model everywhere. It would be nice, for instance, to
> > > > set an
> > > > EvenListener on the @RadioGroup component, and have it propagate the
> > > event
> > > > on nested @Radio components.
> > > >
> > > > Thx
> > > > Ch.
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo/(and a dash of TestNG), team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>
>

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


Re: EventListener on components within a @For loop

Posted by Jesse Kuhnert <jk...@gmail.com>.
Hah! That's pretty cool. I like it :)

If someone files a bug in JIRA I'll look into the radio button stuff
.(though I thought I remembered there being a ticket for this already - at
least I know we had to deal with it in tacos )

On 10/4/06, Christian Dutaret <cd...@gmail.com> wrote:
>
> I found a nice solution using dojo's ability to listen to an arbitrary
> javascript function as if it were a native event.
> I attach an empty js function to an arbitrary DOM element like this:
>
> document.getElementById('someDiv').clickRadio=function(radio) {};
>
> and an onclick attribute to my radio buttons:
>
> <span jwcid="@Radio" value="ognl:lv.value" onclick="
> document.getElementById
> ('someDiv').clickRadio(this);"/>
>
> Then I can set an EventListener on the server-side
>
>     @EventListener(targets = "someDiv", events = "clickRadio", submitForm
> =
> "form")
>     public void listenToOnclickOnAnyRadioButtonInTheForLoop(IRequestCycle
> cycle) throws InterruptedException {
>         ...
>     }
>
> Works fine.
> Ch.
>
>
> 2006/10/3, Dennis Sinelnikov <de...@augustschell.com>:
> >
> > I'm glad someone else has a need for this as well.  From doing a little
> > bit of research the other day, I found @EventListener annotation that
> > was introduced into tapestry 4.1+ that "sort of" fixes the problem. I'm
> > currently using stable release of tapestry 4.0.2, so I didn't bother
> > going that route. I believe this can be accomplished with tacos, but not
> > sure.  If you find something I would love to see an example, I'll do the
> > same as well...
> >
> > Good Luck,
> > Dennis
> >
> > Christian Dutaret wrote:
> > > Hi,
> > >
> > > Is it possible to have an EventListener for events on components
> within
> > a
> > > @For loop? Typically, I have a set of radio buttons, which are
> rendered
> > > from
> > > @Radio components within a @For loop (with a surrounding @RadioGroup
> > > component), and I want to invoke a listener whenever an onclick event
> > > occurs
> > > on any of those radio buttons.
> > > I could achieve this with @contrib:XTile components, but I'd rather
> use
> > the
> > > same programming model everywhere. It would be nice, for instance, to
> > > set an
> > > EvenListener on the @RadioGroup component, and have it propagate the
> > event
> > > on nested @Radio components.
> > >
> > > Thx
> > > Ch.
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo/(and a dash of TestNG), team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

Re: EventListener on components within a @For loop

Posted by Christian Dutaret <cd...@gmail.com>.
I still use this workaround.
To have it work with T4.1.3, I think you just need to set the event on a
form component (I use the submit button).

dojo.byId('submit').ajaxEvent=function(json) {};

then :

@EventListener(targets = "submit", events = "ajaxEvent")
public void onAjaxEvent(IRequestCycle cycle, BrowserEvent event) {
    ...
}

The json parameter can be used to retrieve which iteration in the For loop
initiated the event :

@EventListener(targets = "submit", events = "ajaxEvent")
public void onAjaxEvent(IRequestCycle cycle, BrowserEvent event) {
    int id = event.getMethodArguments().getJSONObject(0).getInt("id");
    ...
}

HTH
Ch.


2008/1/2, caarney <cr...@centrum.cz>:
>
>
> Is anyone using this workaround on Tapestry 4.1.3? I'm getting some dojo
> JavaScript error ("o[i] has no properties"), but it seems to work on Tap.
> 4.1.2.
>
>
>
> Christian Dutaret-3 wrote:
> >
> > I found a nice solution using dojo's ability to listen to an arbitrary
> > javascript function as if it were a native event.
> > I attach an empty js function to an arbitrary DOM element like this:
> >
> > document.getElementById('someDiv').clickRadio=function(radio) {};
> >
> > and an onclick attribute to my radio buttons:
> >
> >
> >
> > Then I can set an EventListener on the server-side
> >
> >     @EventListener(targets = "someDiv", events = "clickRadio",
> submitForm
> > =
> > "form")
> >     public void
> listenToOnclickOnAnyRadioButtonInTheForLoop(IRequestCycle
> > cycle) throws InterruptedException {
> >         ...
> >     }
> >
> > Works fine.
> > Ch.
> >
> >
> > 2006/10/3, Dennis Sinelnikov <de...@augustschell.com>:
> >>
> >> I'm glad someone else has a need for this as well.  From doing a little
> >> bit of research the other day, I found @EventListener annotation that
> >> was introduced into tapestry 4.1+ that "sort of" fixes the problem. I'm
> >> currently using stable release of tapestry 4.0.2, so I didn't bother
> >> going that route. I believe this can be accomplished with tacos, but
> not
> >> sure.  If you find something I would love to see an example, I'll do
> the
> >> same as well...
> >>
> >> Good Luck,
> >> Dennis
> >>
> >> Christian Dutaret wrote:
> >> > Hi,
> >> >
> >> > Is it possible to have an EventListener for events on components
> within
> >> a
> >> > @For loop? Typically, I have a set of radio buttons, which are
> rendered
> >> > from
> >> > @Radio components within a @For loop (with a surrounding @RadioGroup
> >> > component), and I want to invoke a listener whenever an onclick event
> >> > occurs
> >> > on any of those radio buttons.
> >> > I could achieve this with @contrib:XTile components, but I'd rather
> use
> >> the
> >> > same programming model everywhere. It would be nice, for instance, to
> >> > set an
> >> > EvenListener on the @RadioGroup component, and have it propagate the
> >> event
> >> > on nested @Radio components.
> >> >
> >> > Thx
> >> > Ch.
> >> >
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/EventListener-on-components-within-a-%40For-loop-tp6619986p14580875.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: EventListener on components within a @For loop

Posted by caarney <cr...@centrum.cz>.
Is anyone using this workaround on Tapestry 4.1.3? I'm getting some dojo
JavaScript error ("o[i] has no properties"), but it seems to work on Tap.
4.1.2.



Christian Dutaret-3 wrote:
> 
> I found a nice solution using dojo's ability to listen to an arbitrary
> javascript function as if it were a native event.
> I attach an empty js function to an arbitrary DOM element like this:
> 
> document.getElementById('someDiv').clickRadio=function(radio) {};
> 
> and an onclick attribute to my radio buttons:
> 
> 
> 
> Then I can set an EventListener on the server-side
> 
>     @EventListener(targets = "someDiv", events = "clickRadio", submitForm
> =
> "form")
>     public void listenToOnclickOnAnyRadioButtonInTheForLoop(IRequestCycle
> cycle) throws InterruptedException {
>         ...
>     }
> 
> Works fine.
> Ch.
> 
> 
> 2006/10/3, Dennis Sinelnikov <de...@augustschell.com>:
>>
>> I'm glad someone else has a need for this as well.  From doing a little
>> bit of research the other day, I found @EventListener annotation that
>> was introduced into tapestry 4.1+ that "sort of" fixes the problem. I'm
>> currently using stable release of tapestry 4.0.2, so I didn't bother
>> going that route. I believe this can be accomplished with tacos, but not
>> sure.  If you find something I would love to see an example, I'll do the
>> same as well...
>>
>> Good Luck,
>> Dennis
>>
>> Christian Dutaret wrote:
>> > Hi,
>> >
>> > Is it possible to have an EventListener for events on components within
>> a
>> > @For loop? Typically, I have a set of radio buttons, which are rendered
>> > from
>> > @Radio components within a @For loop (with a surrounding @RadioGroup
>> > component), and I want to invoke a listener whenever an onclick event
>> > occurs
>> > on any of those radio buttons.
>> > I could achieve this with @contrib:XTile components, but I'd rather use
>> the
>> > same programming model everywhere. It would be nice, for instance, to
>> > set an
>> > EvenListener on the @RadioGroup component, and have it propagate the
>> event
>> > on nested @Radio components.
>> >
>> > Thx
>> > Ch.
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/EventListener-on-components-within-a-%40For-loop-tp6619986p14580875.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: EventListener on components within a @For loop

Posted by Christian Dutaret <cd...@gmail.com>.
I found a nice solution using dojo's ability to listen to an arbitrary
javascript function as if it were a native event.
I attach an empty js function to an arbitrary DOM element like this:

document.getElementById('someDiv').clickRadio=function(radio) {};

and an onclick attribute to my radio buttons:

<span jwcid="@Radio" value="ognl:lv.value" onclick="document.getElementById
('someDiv').clickRadio(this);"/>

Then I can set an EventListener on the server-side

    @EventListener(targets = "someDiv", events = "clickRadio", submitForm =
"form")
    public void listenToOnclickOnAnyRadioButtonInTheForLoop(IRequestCycle
cycle) throws InterruptedException {
        ...
    }

Works fine.
Ch.


2006/10/3, Dennis Sinelnikov <de...@augustschell.com>:
>
> I'm glad someone else has a need for this as well.  From doing a little
> bit of research the other day, I found @EventListener annotation that
> was introduced into tapestry 4.1+ that "sort of" fixes the problem. I'm
> currently using stable release of tapestry 4.0.2, so I didn't bother
> going that route. I believe this can be accomplished with tacos, but not
> sure.  If you find something I would love to see an example, I'll do the
> same as well...
>
> Good Luck,
> Dennis
>
> Christian Dutaret wrote:
> > Hi,
> >
> > Is it possible to have an EventListener for events on components within
> a
> > @For loop? Typically, I have a set of radio buttons, which are rendered
> > from
> > @Radio components within a @For loop (with a surrounding @RadioGroup
> > component), and I want to invoke a listener whenever an onclick event
> > occurs
> > on any of those radio buttons.
> > I could achieve this with @contrib:XTile components, but I'd rather use
> the
> > same programming model everywhere. It would be nice, for instance, to
> > set an
> > EvenListener on the @RadioGroup component, and have it propagate the
> event
> > on nested @Radio components.
> >
> > Thx
> > Ch.
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: EventListener on components within a @For loop

Posted by Dennis Sinelnikov <de...@augustschell.com>.
I'm glad someone else has a need for this as well.  From doing a little 
bit of research the other day, I found @EventListener annotation that 
was introduced into tapestry 4.1+ that "sort of" fixes the problem. I'm 
currently using stable release of tapestry 4.0.2, so I didn't bother 
going that route. I believe this can be accomplished with tacos, but not 
sure.  If you find something I would love to see an example, I'll do the 
same as well...

Good Luck,
Dennis

Christian Dutaret wrote:
> Hi,
> 
> Is it possible to have an EventListener for events on components within a
> @For loop? Typically, I have a set of radio buttons, which are rendered 
> from
> @Radio components within a @For loop (with a surrounding @RadioGroup
> component), and I want to invoke a listener whenever an onclick event 
> occurs
> on any of those radio buttons.
> I could achieve this with @contrib:XTile components, but I'd rather use the
> same programming model everywhere. It would be nice, for instance, to 
> set an
> EvenListener on the @RadioGroup component, and have it propagate the event
> on nested @Radio components.
> 
> Thx
> Ch.
> 


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