hi,

i have a service in my environment that collects the ids
of the components that need to be enhanced by some sort
of javascript. this service is contributed to the Environment
by a MarkupRendererFilter. after render.renderMarkup
i call my service to generate the necessary javascript using
the RenderSupport service. This also gives me the oppurtunity
to tune the generated scripts :). 

as a side note i most of the time i only generate JSON arrays 
on the server side and let them be interpreted on the client side 
by a javascript function.

g,
kris

MarkupRendererFilter eventListenerScriptRenderer = new 
MarkupRendererFilter()
{
        public void renderMarkup(MarkupWriter writer, MarkupRenderer 
renderer)
        {
                EventListenerScriptRenderer scriptRenderer = new 
EventListenerScriptRendererImpl(renderSupport, uiLib);
                ...
 
                environment.push(EventListenerScriptRenderer.class, 
scriptRenderer);
 
                ...

                renderer.renderMarkup(writer); // have to call this

                ...
                scriptRenderer.generateScript();

                environment.pop(EventListenerScriptRenderer.class);
        }
};

in components/mixins...

@Environmental
EventListenerScriptRenderer scriptRenderer
...






Konstantin <[EMAIL PROTECTED]> 
03.11.2008 12:03
Bitte antworten an
"Tapestry users" <users@tapestry.apache.org>


An
users@tapestry.apache.org
Kopie

Thema
T5: One static initializer script for mixin








I've created AjaxLoader mixin that I use on EventLink with zone param. It
will add nice animated gif inside zone while zone content will be loading.

JS part creates Tapestry.AjaxLoader class.
I've also added Tapestry.Initializer.ajaxLoader with (linkId, zoneId,
loaderURL) params which will simply create new TapestryAjaxLoader inside.

So the question is: I don't want to pass 'loaderURL' param in every init
request. I can introduce "static" member with 
Tapestry.AjaxLoader.loaderURL
= '/images/...../loader.gif'. But where should I put that initializer ? If 
I
put it like this:

    @AfterRender
    void afterRender(MarkupWriter markupWriter) {
        renderSupport.addScript("Tapestry.AjaxLoader.loaderURL = '%s';",
ajaxLoader.toClientURL());

        renderSupport.addInit("ajaxLoader", link.getClientId(), zoneId);
    }

I end up with as many "Tapestry.AjaxLoader.loaderURL='...'" as I have
eventLinks and zones in my page, but I want to have just one.
Can you suggest some nice solution to my problem ?
-- 
View this message in context: 
http://www.nabble.com/T5%3A-One-static-initializer-script-for-mixin-tp20300768p20300768.html

Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to