[ 
https://issues.apache.org/jira/browse/TAP5-1870?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13640131#comment-13640131
 ] 

Paul Stanton commented on TAP5-1870:
------------------------------------

I've figured out that 

JavaScriptSupport.addScript 
a) works if called from setupRender/afterRender whether XHR or not
b) does not work when called from XHR event handlers

AjaxResponseRenderer.addCallback
a) works for XHR event handlers
b) does not work if called from setupRender/afterRender in an XHR request

Therefore, in the case of the setupRender/afterRender in an XHR request is 
tricky .. One must detect that this is the context of the call.
                
> javascript added while in the render phase of a component from an ajax 
> request is never executed
> ------------------------------------------------------------------------------------------------
>
>                 Key: TAP5-1870
>                 URL: https://issues.apache.org/jira/browse/TAP5-1870
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-core
>    Affects Versions: 5.3.2, 5.3.4
>            Reporter: Paul Stanton
>              Labels: ajax, javascript, zone
>
> When a zone update occurs, the 'setupRender' is called for each component 
> contained by that zone.
> If a script is added to ajaxResponseRenderer within the 'setupRender' method 
> it is never executed on the page.
> eg:
> public class MyPage
> {
>     void onSomeEvent()
>     {
>         ajaxResponseRenderer.addRender(myZone); // myZone contains a 
> MyComponent in the tml
>     }
> }
> public class MyComponent
> {
>     void setupRender()
>     {
>         if (request.isXHR())
>             ajaxResponseRenderer.addCallback(new JavaScriptCallback() { 
> public void run(JavaScriptSupport javascriptSupport) {
>                     javascriptSupport.addScript("alert('here');");}});
>     }
> }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to