I have tired to inject the javascript code like this

    @Inject
    private AjaxResponseRenderer ajaxResponseRenderer;

    @AfterRender
    public void set(){
        ajaxResponseRenderer.addCallback(new JavaScriptCallback() {

            @Override
            public void run(JavaScriptSupport javascriptSupport) {
                javascriptSupport.addScript("alert(%s)",
selectedComponent.getId());
            }
        })
    }

but for some reason (anyone know which one?) this didnt work

This on the other had 

    @Environmental
    private JavaScriptSupport javascriptSupport;

    @AfterRender
    public void set() {
        if (selectedComponent != null) {
            javascriptSupport.addScript("selectComponent(itemComponent%s)",
selectedComponent.getId());
        }
    }

is working. So my question is can I use the first approach in same way
(would like to avoid setting up a new variable in the class if possible). 

I think that first apprach has worked when I tried it before but at that
time it was in the ajax request, so in the method that handled the ajax
response. Now I am just refreshing the zone in which there is a component
that has that after render method. 

Anyhow what should be the best way for this? 

Cheers and tnx all

--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Injection-javascript-code-AjaxResponseRenderer-vs-JavaScriptSupport-tp5714464.html
Sent from the Tapestry - User 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

Reply via email to