You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by nquirynen <na...@pensionarchitects.be> on 2012/09/28 11:19:44 UTC

Zone update after ajax request to component event

Hi,

I have a component (grid) where I added a javascript onclick event on my
rows where I do an ajax (jquery) request to a component event:

$.get('${onRowClickEventLink}');

This all works fine, but I also want to update some zones after this event
so I added this to the event method:

void onRowClick() {
...
ajaxResponseRenderer.addRender(aZone);
}

In Firebug I do see in the response the following:

"zones" : {
    "aZone" : ...
}

But the zone does not get updated.
Now I found a workaround where I added a javascript callback function on the
$.get request where I do the following:

function rowClickCalback(r) {
   aZone.html(r.zones.aZone);
}

This does work and makes the zone update, but it does not feel like I am
doing things the right way. I'm pretty new to Tapestry with Ajax, so any
insight in what I am doing wrong is appreciated.

Thanks, 
Nathan




--
View this message in context: http://tapestry.1045711.n5.nabble.com/Zone-update-after-ajax-request-to-component-event-tp5716538.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: Zone update after ajax request to component event

Posted by Lance Java <la...@googlemail.com>.
Take a look at Geoff's ZoneUpdater mixin [1] which fires a serverside event
by listening to a clientside event on a DOM element. You should never update
the innerHTML of a zone directly, use the client-side ZoneManager. If you
are using tapestry-jquery, there is a different implementation of this.

http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/onevent



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Zone-update-after-ajax-request-to-component-event-tp5716538p5716540.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: Zone update after ajax request to component event

Posted by Charlouze <me...@charlouze.com>.
Hey,

I've never used it but if you want to use jQuery, you should take a look at
the tapestry5-jquery plugin : http://tapestry5-jquery.com/

Charles.

2012/9/28 nquirynen <na...@pensionarchitects.be>

> Hi,
>
> I have a component (grid) where I added a javascript onclick event on my
> rows where I do an ajax (jquery) request to a component event:
>
> $.get('${onRowClickEventLink}');
>
> This all works fine, but I also want to update some zones after this event
> so I added this to the event method:
>
> void onRowClick() {
> ...
> ajaxResponseRenderer.addRender(aZone);
> }
>
> In Firebug I do see in the response the following:
>
> "zones" : {
>     "aZone" : ...
> }
>
> But the zone does not get updated.
> Now I found a workaround where I added a javascript callback function on
> the
> $.get request where I do the following:
>
> function rowClickCalback(r) {
>    aZone.html(r.zones.aZone);
> }
>
> This does work and makes the zone update, but it does not feel like I am
> doing things the right way. I'm pretty new to Tapestry with Ajax, so any
> insight in what I am doing wrong is appreciated.
>
> Thanks,
> Nathan
>
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Zone-update-after-ajax-request-to-component-event-tp5716538.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: Zone update after ajax request to component event

Posted by Lance Java <la...@googlemail.com>.
I'm not too familiar with the tapestry-jquery code but perhaps
updateZoneOnEvent(eventName, element, zoneId, url) does exactly what you
want?

https://github.com/got5/tapestry5-jquery/blob/master/src/main/resources/org/got5/tapestry5/jquery/tapestry-jquery.js



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Zone-update-after-ajax-request-to-component-event-tp5716538p5716544.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: Zone update after ajax request to component event

Posted by nquirynen <na...@pensionarchitects.be>.
Yep I use tapestry5-jquery :)

Ok so I added the following code to my javascript click events callback:

	if (responseJSON.zones) {

// perform multi zone update

$.each(responseJSON.zones, function(zoneId) {

$('#' + zoneId).tapestryZone("applyContentUpdate",
responseJSON.zones[zoneId]);
});
$.tapestry.utils.loadScriptsInReply(responseJSON);

}

if (responseJSON.updateZone) {

var spec = {
url : responseJSON.updateZone.url,
params : responseJSON.updateZone.params
};

$('#' + responseJSON.updateZone.zoneId).tapestryZone(
"update", spec);

}

Now my zones get updated and my added scripts get loaded. Is this what I'm
supposed to do?

Thanks all!



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Zone-update-after-ajax-request-to-component-event-tp5716538p5716543.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: Zone update after ajax request to component event

Posted by Emmanuel DEMEY <de...@gmail.com>.
Hi,

If you use Tapestry5-jQuery, you should have a look to this javascript code
:
https://github.com/got5/tapestry5-jquery/blob/master/src/main/resources/org/got5/tapestry5/jquery/assets/components/upload/upload-jquery.js

Manu

2012/9/28 nquirynen <na...@pensionarchitects.be>

> Hi,
>
> I have a component (grid) where I added a javascript onclick event on my
> rows where I do an ajax (jquery) request to a component event:
>
> $.get('${onRowClickEventLink}');
>
> This all works fine, but I also want to update some zones after this event
> so I added this to the event method:
>
> void onRowClick() {
> ...
> ajaxResponseRenderer.addRender(aZone);
> }
>
> In Firebug I do see in the response the following:
>
> "zones" : {
>     "aZone" : ...
> }
>
> But the zone does not get updated.
> Now I found a workaround where I added a javascript callback function on
> the
> $.get request where I do the following:
>
> function rowClickCalback(r) {
>    aZone.html(r.zones.aZone);
> }
>
> This does work and makes the zone update, but it does not feel like I am
> doing things the right way. I'm pretty new to Tapestry with Ajax, so any
> insight in what I am doing wrong is appreciated.
>
> Thanks,
> Nathan
>
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Zone-update-after-ajax-request-to-component-event-tp5716538.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
>
>


-- 
Emmanuel DEMEY
Ingénieur Etude et Développement
ATOS Worldline
+33 (0)6 47 47 42 02
demey.emmanuel@gmail.com
http://emmanueldemey.fr/

Twitter : @EmmanuelDemey

Re: Zone update after ajax request to component event

Posted by Ivan Khalopik <ik...@gmail.com>.
As you use your own zone update mechanism instead of native(e.g. EventLink
component)  you can provide js-callback for ajax request as you mention
before.
To update zone use something like this:

var zone = Tapestry.findZoneManager(spec.zoneId);
function rowClickCalback(response) {
    zone.processReply(response);
}

Or you can update zone with T5 js api:

var zone = Tapestry.findZoneManager(spec.zoneId);
zone.updateFromURL(url, parameters);



On Fri, Sep 28, 2012 at 12:19 PM, nquirynen <na...@pensionarchitects.be>wrote:

> Hi,
>
> I have a component (grid) where I added a javascript onclick event on my
> rows where I do an ajax (jquery) request to a component event:
>
> $.get('${onRowClickEventLink}');
>
> This all works fine, but I also want to update some zones after this event
> so I added this to the event method:
>
> void onRowClick() {
> ...
> ajaxResponseRenderer.addRender(aZone);
> }
>
> In Firebug I do see in the response the following:
>
> "zones" : {
>     "aZone" : ...
> }
>
> But the zone does not get updated.
> Now I found a workaround where I added a javascript callback function on
> the
> $.get request where I do the following:
>
> function rowClickCalback(r) {
>    aZone.html(r.zones.aZone);
> }
>
> This does work and makes the zone update, but it does not feel like I am
> doing things the right way. I'm pretty new to Tapestry with Ajax, so any
> insight in what I am doing wrong is appreciated.
>
> Thanks,
> Nathan
>
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Zone-update-after-ajax-request-to-component-event-tp5716538.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
>
>


-- 
BR
Ivan