Francois is right, the client side can not directly invoke methods of
Tapestry pages or components; this is by design. The component side
can send events to specific components, and then what happens is
totally defined by the server (and therefore, more predictable and
less hackable).

Component event URLs encapsulate the following information:
- Name of containing page
- Id of component
- Name of event
- Event context

By injecting the ComponentResources object into your page, you can
invoke the method createEventLink().  This Link object can be
converted to a string via it's method toAbsoluteURI().  That's the
string your client-side JavaScript needs.

Example:

@Inject
private ComponentResources resources;

@Envrionmental
private RenderSupport renderSupport;

void afterRender()
{
  Link link = resources.createEventLink("getnodes");

  renderSupport.addScript("new MyClientSideObject('%s');",
link.toAbsoluteURI());
}

JSONArray onGetNodes()
{
  return . . . ;
}


The event handler method does not have to be public.  The Link in this
case identifies the page and event name, indicates a null component
(meaning, the page's root component), and has no context.  The URL
will looking something like  /mypage:getnodes  (mypage is the page
name, getnodes is the event name).

On Thu, Dec 18, 2008 at 4:42 AM, Francois Armand <farm...@linagora.com> wrote:
> superoverdr...@gmx.de wrote:
>>
>> Where is this "autocomple mixin" example? I have looked everywhere, but
>> can't find it.
>> Also read about this on the Tapestry website...
>>
>> So you mean something like:
>>
>>
>> @OnEvent(component = "getnodes")
>>
>
> Would be value in place of component, or name your method "onGetnodes()
> {...}
>
> The autocomplete mixin is in the core lib, so you can get the source with T5
> core lib, for example:
> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/Autocomplete.java?view=markup
>
> --
> Francois Armand
> Etudes & Développements J2EE
> Groupe Linagora - http://www.linagora.com
> Tél.: +33 (0)1 58 18 68 28
> -----------
> http://fanf42.blogspot.com
> InterLDAP - http://interldap.org FederID - http://www.federid.org/
> Open Source identities management and federation
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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

Reply via email to