You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Dustin Frazier <du...@philanthropix.org> on 2003/08/20 01:31:56 UTC
form listener on a component?
I've searched the list archives for an answer to this, but nothing is jumping
out at me. I have a component that will be used on multiple pages, and it has
a form on it. I have the following in the component template:
<form jwcid="@Form" listener="ognl:listeners.searchAction">
<td><input jwcid="@TextField" size=20 class=text
value="ognl:searchText"/></td>
<td><input type=submit class=button label="Go!"></td>
</form>
I have the following methods in my component class:
public abstract String getSearchText();
public void searchAction (IRequestCycle cycle) {
Visit visit = (Visit)getPage().getVisit();
visit.doSearch(getSearchText());
cycle.activate("SearchResults");
}
Seems perfectly reasonable, but it doesn't work. Tapestry can't seem to find
the listener defined on the component. I tried adding "direct=false" to the
Form declaration as well. I also tried "ognl:page.listeners.searchAction" for
the "listener" attribute value, thinking that maybe the page's ListenerMap
held *all* the listeners for its components. Wrong again.
This is the first time I've tried to define a listener on the component level
rather than at the page or engine level, and I'm wondering: is this possible?
If not, why not? And what's the clean way of having a form component that's
used on multiple pages? Do I have to put listeners for reusable components on
my engine? Yuck...
Thanks!
Dustin
RE: form listener on a component?
Posted by Dustin Frazier <du...@philanthropix.org>.
"No" to the first question, thanks. Tapestry makes it so easy to *not* write
code, sometimes it's easy to forget to hook things up when you do. :)
By the way, the error message I got was:
Unable to resolve expression 'listeners.searchAction' for
org.apache.tapestry.BaseComponent
$Enhance_70@1ef4b2b[Home/$BasicTemplate.$TopTabs.$QuickSearch].
I guess I was supposed to notice that it was BaseComponent being enhanced
rather than my QuickSearch component class, but the meaning of that part of
the message wasn't immediately obvious...
Thanks!
Dustin
-----Original Message-----
From: Howard M. Lewis Ship [mailto:hlship@comcast.net]
Sent: Tuesday, August 19, 2003 7:26 PM
To: 'Tapestry users'
Subject: RE: form listener on a component?
In your <component-specification>, did you specify the right value for the
class attribute?
This absolutely does work.
Have you set a break point to verify that your method is not being invoked?
--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components http://jakarta.apache.org/tapestry
> -----Original Message-----
> From: Dustin Frazier [mailto:dustin@philanthropix.org]
> Sent: Tuesday, August 19, 2003 7:32 PM
> To: tapestry-user@jakarta.apache.org
> Subject: form listener on a component?
>
>
> I've searched the list archives for an answer to this, but
> nothing is jumping out at me. I have a component that will
> be used on multiple pages, and it has a form on it. I have
> the following in the component template:
>
> <form jwcid="@Form" listener="ognl:listeners.searchAction">
> <td><input jwcid="@TextField" size=20 class=text
> value="ognl:searchText"/></td>
> <td><input type=submit class=button label="Go!"></td>
> </form>
>
> I have the following methods in my component class:
>
> public abstract String getSearchText();
>
> public void searchAction (IRequestCycle cycle) {
> Visit visit = (Visit)getPage().getVisit();
> visit.doSearch(getSearchText());
> cycle.activate("SearchResults");
> }
>
> Seems perfectly reasonable, but it doesn't work. Tapestry
> can't seem to find the listener defined on the component. I
> tried adding "direct=false" to the Form declaration as well.
> I also tried "ognl:page.listeners.searchAction" for the
> "listener" attribute value, thinking that maybe the page's
> ListenerMap held *all* the listeners for its components. Wrong again.
>
> This is the first time I've tried to define a listener on the
> component level rather than at the page or engine level, and
> I'm wondering: is this possible? If not, why not? And what's
> the clean way of having a form component that's used on
> multiple pages? Do I have to put listeners for reusable
> components on my engine? Yuck...
>
> Thanks!
>
> Dustin
>
>
> ---------------------------------------------------------------------
> 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
RE: form listener on a component?
Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
In your <component-specification>, did you specify the right value for the class attribute?
This absolutely does work.
Have you set a break point to verify that your method is not being invoked?
--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry
> -----Original Message-----
> From: Dustin Frazier [mailto:dustin@philanthropix.org]
> Sent: Tuesday, August 19, 2003 7:32 PM
> To: tapestry-user@jakarta.apache.org
> Subject: form listener on a component?
>
>
> I've searched the list archives for an answer to this, but
> nothing is jumping out at me. I have a component that will
> be used on multiple pages, and it has a form on it. I have
> the following in the component template:
>
> <form jwcid="@Form" listener="ognl:listeners.searchAction">
> <td><input jwcid="@TextField" size=20 class=text
> value="ognl:searchText"/></td>
> <td><input type=submit class=button label="Go!"></td>
> </form>
>
> I have the following methods in my component class:
>
> public abstract String getSearchText();
>
> public void searchAction (IRequestCycle cycle) {
> Visit visit = (Visit)getPage().getVisit();
> visit.doSearch(getSearchText());
> cycle.activate("SearchResults");
> }
>
> Seems perfectly reasonable, but it doesn't work. Tapestry
> can't seem to find the listener defined on the component. I
> tried adding "direct=false" to the Form declaration as well.
> I also tried "ognl:page.listeners.searchAction" for the
> "listener" attribute value, thinking that maybe the page's
> ListenerMap held *all* the listeners for its components. Wrong again.
>
> This is the first time I've tried to define a listener on the
> component level rather than at the page or engine level, and
> I'm wondering: is this possible? If not, why not? And what's
> the clean way of having a form component that's used on
> multiple pages? Do I have to put listeners for reusable
> components on my engine? Yuck...
>
> Thanks!
>
> Dustin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>