[5.4] request from javascript to Tapestry event

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[5.4] request from javascript to Tapestry event

nquirynen
Hi,

I have finally started the process of updating to 5.4.
Some components have an initializer javascript where an eventlink url is
passed as a parameter to be used as the url for a request from
javascript to a Tapestry event.
To handle the response (zone updates, scripts, ..) I added in the
request callback function the following:

$.get(spec.eventLink, function(r) {

     if (r.zones) {
         $.each(r.zones, function(zoneId){
             $('#' + zoneId).tapestryZone("applyContentUpdate",
r.zones[zoneId]);
         });
     }

     if (r.updateZone) {
         var spec = {
             url: r.updateZone.url,
             params: r.updateZone.params
         };
         $('#' + r.updateZone.zoneId).tapestryZone("update", spec);
     }
     $.tapestry.utils.loadScriptsInReply(r);

});

I thought this was not the best solution, but did not find another one
at the moment and it worked.
Now in 5.4 it does not work anymore, so how do I have to fire requests
to tapestry events from javascript and make it handle the response?

Nathan

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [5.4] request from javascript to Tapestry event

Chris Poulsen
Have a look at http://tapestry.apache.org/current/coffeescript/ajax.html

--
Chris

On Fri, Feb 5, 2016 at 2:54 PM, Nathan Quirynen <[hidden email]
> wrote:

> Hi,
>
> I have finally started the process of updating to 5.4.
> Some components have an initializer javascript where an eventlink url is
> passed as a parameter to be used as the url for a request from javascript
> to a Tapestry event.
> To handle the response (zone updates, scripts, ..) I added in the request
> callback function the following:
>
> $.get(spec.eventLink, function(r) {
>
>     if (r.zones) {
>         $.each(r.zones, function(zoneId){
>             $('#' + zoneId).tapestryZone("applyContentUpdate",
> r.zones[zoneId]);
>         });
>     }
>
>     if (r.updateZone) {
>         var spec = {
>             url: r.updateZone.url,
>             params: r.updateZone.params
>         };
>         $('#' + r.updateZone.zoneId).tapestryZone("update", spec);
>     }
>     $.tapestry.utils.loadScriptsInReply(r);
>
> });
>
> I thought this was not the best solution, but did not find another one at
> the moment and it worked.
> Now in 5.4 it does not work anymore, so how do I have to fire requests to
> tapestry events from javascript and make it handle the response?
>
> Nathan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [5.4] request from javascript to Tapestry event

Chris Poulsen
Faking a "click" on an invisible async eventlink could also be a very
simple way to get this working without having to mock around with much
javascript.

--
Chris

On Fri, Feb 5, 2016 at 3:04 PM, Chris Poulsen <[hidden email]>
wrote:

> Have a look at http://tapestry.apache.org/current/coffeescript/ajax.html
>
> --
> Chris
>
> On Fri, Feb 5, 2016 at 2:54 PM, Nathan Quirynen <
> [hidden email]> wrote:
>
>> Hi,
>>
>> I have finally started the process of updating to 5.4.
>> Some components have an initializer javascript where an eventlink url is
>> passed as a parameter to be used as the url for a request from javascript
>> to a Tapestry event.
>> To handle the response (zone updates, scripts, ..) I added in the request
>> callback function the following:
>>
>> $.get(spec.eventLink, function(r) {
>>
>>     if (r.zones) {
>>         $.each(r.zones, function(zoneId){
>>             $('#' + zoneId).tapestryZone("applyContentUpdate",
>> r.zones[zoneId]);
>>         });
>>     }
>>
>>     if (r.updateZone) {
>>         var spec = {
>>             url: r.updateZone.url,
>>             params: r.updateZone.params
>>         };
>>         $('#' + r.updateZone.zoneId).tapestryZone("update", spec);
>>     }
>>     $.tapestry.utils.loadScriptsInReply(r);
>>
>> });
>>
>> I thought this was not the best solution, but did not find another one at
>> the moment and it worked.
>> Now in 5.4 it does not work anymore, so how do I have to fire requests to
>> tapestry events from javascript and make it handle the response?
>>
>> Nathan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: [5.4] request from javascript to Tapestry event

nquirynen
In reply to this post by Chris Poulsen
Thanks for the link.
I think I fixed it adding just the following in my request callback
function:

pageinit.handlePartialPageRenderResponse({ json : r });

On 05/02/16 15:04, Chris Poulsen wrote:
> Have a look at http://tapestry.apache.org/current/coffeescript/ajax.html
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]