Ah, you're right. You can't add script during the action phase, you need to add the script when the zones are rendering.
Try this: @Inject private RenderSupport _support; @Inject private PageRenderQueue _queue; MultiZoneUpdate onHello() { _queue.addPartialMarkupRendererFilter(new PartialMarkupRendererFilter() { public void renderMarkup(MarkupWriter writer, JSONObject reply, PartialMarkupRenderer renderer) { _support.addScript("alert('I am script');"); renderer.renderMarkup(writer, reply); } }); return new MultiZoneUpdate("test", _timeBlock); } Josh On Sun, May 23, 2010 at 10:45 PM, Paul Stanton <p...@mapshed.com.au> wrote: > Thanks for the ideas Josh, Hopefully I can get some use out of them... > > I am creating the Ajax.Request myself as this is essentially what the > Autocompleter does which is the best example I can find. I am infact > extending the Autocompleter so that I can trigger an Ajax communication when > an item is selected from the autocomplete suggestions. Essentially this is > the same as having an actionlink, in that I am using > ComponentResources.createEventLink().toAbsoluteURI() to determine the URL to > call via Ajax.Request. The listener on the other end returns the > MultiZoneUpdate. > > I've tried injecting RenderSupport: > @Inject private RenderSupport renderSupport; > > But the following exception is thrown: > > Caused by: java.lang.RuntimeException: No object of type > org.apache.tapestry5.RenderSupport is available from the Environment. > Available types are > org.apache.tapestry5.services.ComponentEventResultProcessor. > at > org.apache.tapestry5.internal.services.EnvironmentImpl.peekRequired(EnvironmentImpl.java:79) > at $Environment_128c8ccda65.peekRequired($Environment_128c8ccda65.java) > at $Environment_128c8ccd9c6.peekRequired($Environment_128c8ccd9c6.java) > at $RenderSupport_128c8ccda6d._delegate($RenderSupport_128c8ccda6d.java) > at $RenderSupport_128c8ccda6d.addScript($RenderSupport_128c8ccda6d.java) > at $RenderSupport_128c8ccda25.addScript($RenderSupport_128c8ccda25.java) > > I believe this is because it's invalid in the context of a partial render > (ajax server side event listener). Have you tried injecting RenderSupport > and using it in your example 'Object onActionFromUpdate()' ? I don't think > it would work, because it is essentially the same architecture as what I > have, minus the actionlink component. > > p. > > Josh Canfield wrote: >>> >>> I've recently come up with a solution for handling MultiZoneUpdate as the >>> response from an Ajax.Request. >>> >> >> I'm not sure I follow why you need to create your own Ajax.Request >> instead of using one of the built-in action/event link components. You >> can give it the name of one zone but return a MultiZoneUpdate >> response. >> >> (from tapestry core MultiZoneUpdateDemo.tml ) >> <t:actionlink t:id="update" zone="fred">update</t:actionlink> >> >> (from tapestry-core MultiZoneUpdateDemo.java) >> Object onActionFromUpdate() >> { >> return new MultiZoneUpdate("fred", fredBlock).add("barney", >> barneyBlock).add("dino", "His dog, Dino."); >> } >> >> >>> >>> Now I need to add the ability to execute a script, generated (or values >>> populated) by the server. >>> >>> >> >> @Inject RenderSupport and call the addScript methods. If you're using >> the built-in components then they get handled by default. The code >> that does that is in ZoneManager.processReply. >> >> Is this what you are trying to do? >> >> Josh >> >> On Sun, May 23, 2010 at 5:13 PM, Paul Stanton <p...@mapshed.com.au> wrote: >> >>> >>> Hi all, >>> >>> I've recently come up with a solution for handling MultiZoneUpdate as the >>> response from an Ajax.Request. >>> >>> I did this by creating the following javascript function and calling it >>> in >>> Ajax.Request.onSuccess: >>> >>> Tapestry.handleMultizoneUpdate = function (transport) >>> { >>> var reply = transport.responseJSON; >>> // copied from tapestry.js - ZoneManager.processReply >>> // apparently exposed in t5.2 >>> Object.keys(reply.zones).each(function (zoneId) { >>> var manager = Tapestry.findZoneManagerForZone(zoneId); >>> if (manager) { >>> var zoneContent = reply.zones[zoneId]; >>> manager.show(zoneContent); >>> } >>> }); >>> }; >>> >>> Now I need to add the ability to execute a script, generated (or values >>> populated) by the server. >>> >>> 1. Where is the code that turns MultiZoneUpdate into JSON? >>> 2. What is the best way to return a javascript snippet from a tapestry >>> event >>> listener to the client and have it executed in an Ajax/XHR environment? >>> >>> Thanks, p. >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >>> For additional commands, e-mail: users-h...@tapestry.apache.org >>> >>> >>> >> >> >> >> > -- -- http://www.bodylabgym.com - a private, by appointment only, one-on-one health and fitness facility. -- http://www.ectransition.com - Quality Electronic Cigarettes at a reasonable price! -- TheDailyTube.com. Sign up and get the best new videos on the internet delivered fresh to your inbox. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org