You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by pantera9 <ei...@gmail.com> on 2012/02/23 11:11:37 UTC

eventLink to an event in a component

In layout.tml, I have a "global" link that needs to call a method in a
component that's on the bottom of layout.tml.

The link looks something like this:


   ${context:layout/images/user-icon.png}         


The component that resides at the bottom of layout.tml:

<t:myComponent t:id="myComponent" />

The html in the component is rendered correctly, but the link fails when
clicked:
"Request event 'myevent' (on component administer/Document:layout) was not
handled; you must provide a matching event handler method in the component
or in one of its containers."

Note: if I put the event handler in layout.java, it works - but that is of
course not a solution.

Any ideas?


Mycomponent.tml, partial:
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;>
<t:container xmlns="http://www.w3.org/1999/xhtml"
		  xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
		  xmlns:p="tapestry:parameter">
  <div id="formPanel" style="display: none;" class="clear-float">
     more html...
  </div>
</t:container>

Mycomponent.java:
package xx.xx.xx.components;

public class Mycomponent {
	@Inject
	private Logger log;
	
	@Log
	@OnEvent("myEvent")
	Object myEvent() {
		log.debug("myEvent() invoked");
		return true;
	}
}


--
View this message in context: http://tapestry.1045711.n5.nabble.com/eventLink-to-an-event-in-a-component-tp5507572p5507572.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: eventLink to an event in a component

Posted by pantera9 <ei...@gmail.com>.
That works fine! thanks :)

--
View this message in context: http://tapestry.1045711.n5.nabble.com/eventLink-to-an-event-in-a-component-tp5507572p5507787.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: eventLink to an event in a component

Posted by Paul Stanton <pa...@mapshed.com.au>.
You could use @InjectComponent to inject the component into your Layout 
class, and then call whatever method needs calling directly from your 
handler in Layout:

public class Layout
{
     @InjectComponent private YourComponent yourComponent;

     void onSomeEvent(String context)
     {
         yourComponent.onSomeEvent(context);
     }
}

On 23/02/2012 9:11 PM, pantera9 wrote:
> In layout.tml, I have a "global" link that needs to call a method in a
> component that's on the bottom of layout.tml.
>
> The link looks something like this:
>
>
>     ${context:layout/images/user-icon.png}
>
>
> The component that resides at the bottom of layout.tml:
>
> <t:myComponent t:id="myComponent" />
>
> The html in the component is rendered correctly, but the link fails when
> clicked:
> "Request event 'myevent' (on component administer/Document:layout) was not
> handled; you must provide a matching event handler method in the component
> or in one of its containers."
>
> Note: if I put the event handler in layout.java, it works - but that is of
> course not a solution.
>
> Any ideas?
>
>
> Mycomponent.tml, partial:
> <!DOCTYPE html PUBLIC&quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
> &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;>
> <t:container xmlns="http://www.w3.org/1999/xhtml"
> 		  xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
> 		  xmlns:p="tapestry:parameter">
>    <div id="formPanel" style="display: none;" class="clear-float">
>       more html...
>    </div>
> </t:container>
>
> Mycomponent.java:
> package xx.xx.xx.components;
>
> public class Mycomponent {
> 	@Inject
> 	private Logger log;
> 	
> 	@Log
> 	@OnEvent("myEvent")
> 	Object myEvent() {
> 		log.debug("myEvent() invoked");
> 		return true;
> 	}
> }
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/eventLink-to-an-event-in-a-component-tp5507572p5507572.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
>
>

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