this is tapestry 5.3

On 19/04/2013 11:28 AM, Paul Stanton wrote:
Hi all,

Can someone familiar with the mixin lifecycle please advise me:

I have a mixin which triggers some javascript from 'afterRender'. I do this in 'afterRender' because I need the field's clientId to be initialised.

It works great if the Field it attaches to is rendered when the page is first rendered, however if it is rendered as part of a zone update/xhr request, the script is never sent to the client.

I have breakpointed the JavaScriptCallback and while it is successfully added to the ajaxResponseRenderer, it is never called.

Thanks for advice!


code Eg:

public class MyMixin
{
    ...

    void afterRender()
    {
addScript("MyMixin.create('%s', '%s');", field.getClientId(), myVariable);
    }

    private void addScript(final String format, final Object... args)
    {
        if (!request.isXHR())
        {
jsSupport.addScript(InitializationPriority.NORMAL, format, args);
            return;
        }

        ajaxResponseRenderer.addCallback(new JavaScriptCallback()
        {
            @Override
            public void run(JavaScriptSupport javascriptSupport)
            {
javascriptSupport.addScript(InitializationPriority.NORMAL, format, args);
            }
        });
    }
}

---------------------------------------------------------------------
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

Reply via email to