This is an old thread and there are better ways to construct event links than manually crafting them (ComponentResources.createXXXLink...). However, if you just want it "both ways" - you've got some zones and ajax actionlinks but also might want to update them via Javascript, here's a simple way to do it: renderSupport.addScript("Event.observe(window, 'load', function() {$('myaction').simulate('click')});");
Where myaction is the id of an actionlink. Note that there are two things that further complicate the situation: the script needs to be executed after Tapestry initialization (this is where the Event.observe comes in) and that Element.fire is for non-native browser events. Prototype doesn't have have a built-in cross-browser way to simulate native events (dispatchEvent in Firefox etc...), but I was able to find this great extension for just that purpose: http://github.com/kangax/protolicious/blob/master/event.simulate.js. You need to load simulate.js on your page and off you go firing native events! Kalle On Thu, Nov 27, 2008 at 5:40 AM, britske <gbr...@gmail.com> wrote: > > Ok I simplified my use-case and decided to try and call the javascript > function from a button instead of on dom-loaded (parhaps something there is > messing with it). Moreover I discovered that I mistakinly assumed that I > needed to include the t:zone as parameter to the url. Moreover I changed the > ajax-get to a post so it is exactly in line with the request performed > through the actionlink. > > so : > new Ajax.Request('/thepage.refreshzone?t:zone=zone1;t:ac=/id-1-66590/', { > method:'get' }); > gets: > new Ajax.Request('/thepage.refreshzone?:ac=/id-1-66590/', { method:'post' > }); > > now the method onActionFromRefreshZone is correctly called but the returned > component (a subclass of AbstractTab) is not rendered. The strange thing is > that as far as I can tell the callstack is exactly the same as when called > with an actionlink (in which case the component is rendered) > For instance, in both cases abstractTab.setupRender() is called, etc. > > public AbstractTab onActionFromRefreshZone() { > nrOfReqs ++; > if (!request.isXHR()) { > return null; > } > > return curTab; > } > > Anyone have any clue why this might be happening? > > > britske wrote: >> >> Hi, >> >> I've created a zone which get's a couple of updates from various external >> websites. The zone initally (on page load) contains some local info, but >> needs to be dynamically extends with the sources extracted from these >> websites. I want to call a server-side method (onActionFromRefreshZone) >> which updates this zone (and starts fetching the info from the external >> websites) on the dom-loaded event. >> >> The zone is in place and I checked that it works with an actionlink: >> # update >> >> However as said I want to call the method onActionFromRefreshZone on >> dom-loaded. >> I already have the javascript method in place which is called on this >> event.However I have no clue how to call the method in a Asynchrnous way. >> I tried including the url of the above actionlink as such: >> >> function functionWhichIsCalledOnDomLoaded(){ >> new >> Ajax.Request('/thepage.refreshzone?t:zone=zone1;t:ac=/id-1-66590/', { >> method:'get' }); >> } >> >> but this doens't work. >> Somehow I'm thinking this isn't the correct way anyhow and that there >> should be a more elegant way / more T5-way to call a server-side method >> asynchronously. >> >> Thanks, >> Geert-Jan >> > > -- > View this message in context: > http://n2.nabble.com/T5%3A-how-to-update-zone-on-dom-load-tp1584917p1585109.html > Sent from the Tapestry Users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > 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