Hi,

Here's what I do to do to raise an arbitrary AJAX event on a component:
1. Inject ComponentResources into the component (let's say the
variable is named "resources").
2. In the component's setupRender handler, call
resources.createEventLink and store the returned Link in a field.  You
can bake or curry values into the returned Link (using the second
argument) so it will always call the event handler with those values.
3. Pass link.toUri() to client javascript you write using
JavaScriptSupport. I usually prefer to use addInitializerCall (in the
afterRender handler) and create an object in the Tapestry.Initializer
namespace in a separate JS file, passing a single configuration object
made with JSONObject in the component.
4. In the JavaScript, execute "new Ajax.Request" or
"Tapestry.ajaxRequest" on the URI (see prototype docs and/or
tapestry.js for details).
5. The event handler "onXyzzy" gets executed (assuming you passed
"xyzzy" to createEventLink).

Hope this helps,
Les Baker

On Tue, Jan 3, 2012 at 1:08 AM, Paul Stanton <p...@mapshed.com.au> wrote:
> Hi all,
>
> I've started using T5.3 for the latest project and am migrating some of the
> ajax api 'extensions' I had to write in order to become productive.
>
> I've noticed that much has improved since T5.1 and am eager to make sure
> that I am not missing out on further improvements by re-implementing my old
> hacks! I used to rely heavily on there being a "dummyZone" - an empty zone
> on every page used to wire up miscellaneous functionality.
>
> Specifically,
>
> 1. Is there a better way to invoke ajax requests (similar to eventlink)
> direct from javascript than the method detailed here:
> https://issues.apache.org/jira/browse/TAP5-1405
> ?
>
> 2. Is there a way to construct an ajax callback (ie eventlink, directlink,
> form etc) without a specifying a zone? - ie, is the 'zone' parameter still
> the only way to transform an eventlink into an async-eventlink and if a
> non-existant zone is specified, does it fail?
> (this would be handy when the ajax callback returns only javascript commands
> or when zone updates are generated dynamically and there is no definitive
> zone to update).
> - i think i logged a jira for this, but can't find it.
>
> Thanks, Paul.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>

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

Reply via email to