You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mark Reynolds <ma...@gmail.com> on 2006/11/25 00:04:36 UTC

@EventListener inside of a component

I am trying to create a reusuable component that encapsulates the
functionality of two related PropertySelection components.

I placed an @EventListerner annotation on a method inside of my component
class.

public abstract class MySelection extends BaseComponent {

    @EventListener(events = "onchange", elements = "item", submitForm =
"form")
    public void onItemSelected(IRequestCycle cycle, BrowserEvent event) {
        // do something
    }

    <snip>

}

I get an exception like this:

Exception: Object $MyPage_43@3c1[MyPage] does not implement a listener
method named 'onItemSelected'.
org.apache.hivemind.ApplicationRuntimeException

It seems that Tapestry is looking for the method on the page class, not in
the embedded component class where the annotated method lives. Normally,
when I reference a listener method from within a compoonent (for instance on
a DirectLink or a Submit), tapestry will find the listener method on the
component class.

Am I doing something wrong here or might this be a bug?

Also, in the annotation, I have to specify the name of the form. Assuming I
can have an @EventListener annotation inside a component, It seems a bit
awkward for the component to need to know what the name of the form happens
to be in which it is enclosed. Is there a dynamic way to specify the form?

Re: @EventListener inside of a component

Posted by Alexandru Dragomir <al...@gmail.com>.
Perhaps the tapestry.linkOnClick(url,id,isJson) will do the trick.
In the url you can put the info you want to send to the server.

Take a look at the timetracker application for a sample of how to use it.

Cheers,
Alex

On 12/29/06, Roberto Ramírez Vique <ro...@gmail.com> wrote:
>
> Hello Jesse & Mark,
>
> I am in the same situation as Mark was some time ago, at least I think the
> situation is the same. This email is to know if there is any other way to
> solve my problem.
>
> I want to have a component which has a simple EventListener to that goes
> to
> the server and changes some values in the client (typical ajax). The
> problem
> is that this component doesn't have a form, the component finally will be
> inside a form, but is not defined in the component itself and the name of
> the form can change.
> As far as I understood, we cannot use the nice EventListener to receive
> information (value of the input types) from the browser except we specify
> the form name, but in my situation the form name will change every time
> and
> I need to define this as a parameter or have a default value for example
> the
> enclosing form for the event source...
>
> I think this, maybe, can be done with some javascript, maybe
> tapestry.form.submitAsync(form, content, submitName, validate)...But I'm
> not
> sure.
> Another question, is if this can be done in that way?
>
> BTW, I'm working with Tapestry 4.1.2, jdk 1.5 and tomcat 5.5.
>
> Thanks you in advance,
>          robert
>
> On 11/25/06, Jesse Kuhnert < jkuhnert@gmail.com> wrote:
> >
> > No, it may very well be a bug. I wouldn't be surprised at least. I'm
> > still busy trying to refactor/etc the For component to work under
> > these "dynamic" conditions a little more friendlier but if a bug is
> > filed I will have a much better chance of remembering. (whereas emails
> > to this list are only likely to have about a 10-30% chance of being
> > fixed unless I run into them myself ;) )
> >
> > On 11/24/06, Mark Reynolds < mark.reynolds.name@gmail.com> wrote:
> > > After looking at this some more, it seems to me that listener methods
> > can't
> > > be in components (that is, if a component is contained within another
> > > component, the container won't get the event, the page will). I think
> I
> > was
> > > wrong about DirectLink and Submit. In any case, I put my
> @EventListener
> > on
> > > the page class and make a call my component to let it know what
> changed.
> > I
> > > am sure there must be a better way that allows me to encapsulate all
> the
> > > logic within my component, so if anyone can point me in the right
> > direction,
> > > that would be great.
> > >
> > > On 11/24/06, Mark Reynolds < mark.reynolds.name@gmail.com> wrote:
> > > >
> > > > I am trying to create a reusuable component that encapsulates the
> > > > functionality of two related PropertySelection components.
> > > >
> > > > I placed an @EventListerner annotation on a method inside of my
> > component
> > > > class.
> > > >
> > > > public abstract class MySelection extends BaseComponent {
> > > >
> > > >     @EventListener(events = "onchange", elements = "item",
> submitForm
> > =
> > > > "form")
> > > >     public void onItemSelected(IRequestCycle cycle, BrowserEvent
> > event) {
> > > >         // do something
> > > >     }
> > > >
> > > >     <snip>
> > > >
> > > > }
> > > >
> > > > I get an exception like this:
> > > >
> > > > Exception: Object $MyPage_43@3c1[MyPage] does not implement a
> listener
> >
> > > > method named 'onItemSelected'.
> > > > org.apache.hivemind.ApplicationRuntimeException
> > > >
> > > > It seems that Tapestry is looking for the method on the page class,
> > not in
> > > > the embedded component class where the annotated method lives.
> > Normally,
> > > > when I reference a listener method from within a compoonent (for
> > instance on
> > > > a DirectLink or a Submit), tapestry will find the listener method on
> > the
> > > > component class.
> > > >
> > > > Am I doing something wrong here or might this be a bug?
> > > >
> > > > Also, in the annotation, I have to specify the name of the form.
> > Assuming
> > > > I can have an @EventListener annotation inside a component, It seems
> a
> > bit
> > > > awkward for the component to need to know what the name of the form
> > happens
> > > > to be in which it is enclosed. Is there a dynamic way to specify the
> > form?
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
> > --
> > 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
> >
> >
>
>
> --
> Robert Ramírez Vique
> Computer Science Engineer
>
>

Re: @EventListener inside of a component

Posted by Roberto Ramírez Vique <ro...@gmail.com>.
Hello Jesse & Mark,

I am in the same situation as Mark was some time ago, at least I think the
situation is the same. This email is to know if there is any other way to
solve my problem.

I want to have a component which has a simple EventListener to that goes to
the server and changes some values in the client (typical ajax). The problem
is that this component doesn't have a form, the component finally will be
inside a form, but is not defined in the component itself and the name of
the form can change.
As far as I understood, we cannot use the nice EventListener to receive
information (value of the input types) from the browser except we specify
the form name, but in my situation the form name will change every time and
I need to define this as a parameter or have a default value for example the
enclosing form for the event source...

I think this, maybe, can be done with some javascript, maybe
tapestry.form.submitAsync(form, content, submitName, validate)...But I'm not
sure.
Another question, is if this can be done in that way?

BTW, I'm working with Tapestry 4.1.2, jdk 1.5 and tomcat 5.5.

Thanks you in advance,
         robert

On 11/25/06, Jesse Kuhnert < jkuhnert@gmail.com> wrote:
>
> No, it may very well be a bug. I wouldn't be surprised at least. I'm
> still busy trying to refactor/etc the For component to work under
> these "dynamic" conditions a little more friendlier but if a bug is
> filed I will have a much better chance of remembering. (whereas emails
> to this list are only likely to have about a 10-30% chance of being
> fixed unless I run into them myself ;) )
>
> On 11/24/06, Mark Reynolds < mark.reynolds.name@gmail.com> wrote:
> > After looking at this some more, it seems to me that listener methods
> can't
> > be in components (that is, if a component is contained within another
> > component, the container won't get the event, the page will). I think I
> was
> > wrong about DirectLink and Submit. In any case, I put my @EventListener
> on
> > the page class and make a call my component to let it know what changed.
> I
> > am sure there must be a better way that allows me to encapsulate all the
> > logic within my component, so if anyone can point me in the right
> direction,
> > that would be great.
> >
> > On 11/24/06, Mark Reynolds < mark.reynolds.name@gmail.com> wrote:
> > >
> > > I am trying to create a reusuable component that encapsulates the
> > > functionality of two related PropertySelection components.
> > >
> > > I placed an @EventListerner annotation on a method inside of my
> component
> > > class.
> > >
> > > public abstract class MySelection extends BaseComponent {
> > >
> > >     @EventListener(events = "onchange", elements = "item", submitForm
> =
> > > "form")
> > >     public void onItemSelected(IRequestCycle cycle, BrowserEvent
> event) {
> > >         // do something
> > >     }
> > >
> > >     <snip>
> > >
> > > }
> > >
> > > I get an exception like this:
> > >
> > > Exception: Object $MyPage_43@3c1[MyPage] does not implement a listener
>
> > > method named 'onItemSelected'.
> > > org.apache.hivemind.ApplicationRuntimeException
> > >
> > > It seems that Tapestry is looking for the method on the page class,
> not in
> > > the embedded component class where the annotated method lives.
> Normally,
> > > when I reference a listener method from within a compoonent (for
> instance on
> > > a DirectLink or a Submit), tapestry will find the listener method on
> the
> > > component class.
> > >
> > > Am I doing something wrong here or might this be a bug?
> > >
> > > Also, in the annotation, I have to specify the name of the form.
> Assuming
> > > I can have an @EventListener annotation inside a component, It seems a
> bit
> > > awkward for the component to need to know what the name of the form
> happens
> > > to be in which it is enclosed. Is there a dynamic way to specify the
> form?
> > >
> > >
> > >
> >
> >
>
>
> --
> 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
>
>


-- 
Robert Ramírez Vique
Computer Science Engineer

Re: @EventListener inside of a component

Posted by Jesse Kuhnert <jk...@gmail.com>.
No, it may very well be a bug. I wouldn't be surprised at least. I'm
still busy trying to refactor/etc the For component to work under
these "dynamic" conditions a little more friendlier but if a bug is
filed I will have a much better chance of remembering. (whereas emails
to this list are only likely to have about a 10-30% chance of being
fixed unless I run into them myself ;) )

On 11/24/06, Mark Reynolds <ma...@gmail.com> wrote:
> After looking at this some more, it seems to me that listener methods can't
> be in components (that is, if a component is contained within another
> component, the container won't get the event, the page will). I think I was
> wrong about DirectLink and Submit. In any case, I put my @EventListener on
> the page class and make a call my component to let it know what changed. I
> am sure there must be a better way that allows me to encapsulate all the
> logic within my component, so if anyone can point me in the right direction,
> that would be great.
>
> On 11/24/06, Mark Reynolds <ma...@gmail.com> wrote:
> >
> > I am trying to create a reusuable component that encapsulates the
> > functionality of two related PropertySelection components.
> >
> > I placed an @EventListerner annotation on a method inside of my component
> > class.
> >
> > public abstract class MySelection extends BaseComponent {
> >
> >     @EventListener(events = "onchange", elements = "item", submitForm =
> > "form")
> >     public void onItemSelected(IRequestCycle cycle, BrowserEvent event) {
> >         // do something
> >     }
> >
> >     <snip>
> >
> > }
> >
> > I get an exception like this:
> >
> > Exception: Object $MyPage_43@3c1[MyPage] does not implement a listener
> > method named 'onItemSelected'.
> > org.apache.hivemind.ApplicationRuntimeException
> >
> > It seems that Tapestry is looking for the method on the page class, not in
> > the embedded component class where the annotated method lives. Normally,
> > when I reference a listener method from within a compoonent (for instance on
> > a DirectLink or a Submit), tapestry will find the listener method on the
> > component class.
> >
> > Am I doing something wrong here or might this be a bug?
> >
> > Also, in the annotation, I have to specify the name of the form. Assuming
> > I can have an @EventListener annotation inside a component, It seems a bit
> > awkward for the component to need to know what the name of the form happens
> > to be in which it is enclosed. Is there a dynamic way to specify the form?
> >
> >
> >
>
>


-- 
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 inside of a component

Posted by Mark Reynolds <ma...@gmail.com>.
After looking at this some more, it seems to me that listener methods can't
be in components (that is, if a component is contained within another
component, the container won't get the event, the page will). I think I was
wrong about DirectLink and Submit. In any case, I put my @EventListener on
the page class and make a call my component to let it know what changed. I
am sure there must be a better way that allows me to encapsulate all the
logic within my component, so if anyone can point me in the right direction,
that would be great.

On 11/24/06, Mark Reynolds <ma...@gmail.com> wrote:
>
> I am trying to create a reusuable component that encapsulates the
> functionality of two related PropertySelection components.
>
> I placed an @EventListerner annotation on a method inside of my component
> class.
>
> public abstract class MySelection extends BaseComponent {
>
>     @EventListener(events = "onchange", elements = "item", submitForm =
> "form")
>     public void onItemSelected(IRequestCycle cycle, BrowserEvent event) {
>         // do something
>     }
>
>     <snip>
>
> }
>
> I get an exception like this:
>
> Exception: Object $MyPage_43@3c1[MyPage] does not implement a listener
> method named 'onItemSelected'.
> org.apache.hivemind.ApplicationRuntimeException
>
> It seems that Tapestry is looking for the method on the page class, not in
> the embedded component class where the annotated method lives. Normally,
> when I reference a listener method from within a compoonent (for instance on
> a DirectLink or a Submit), tapestry will find the listener method on the
> component class.
>
> Am I doing something wrong here or might this be a bug?
>
> Also, in the annotation, I have to specify the name of the form. Assuming
> I can have an @EventListener annotation inside a component, It seems a bit
> awkward for the component to need to know what the name of the form happens
> to be in which it is enclosed. Is there a dynamic way to specify the form?
>
>
>