Thanks .. :-)

That's enough to get us started. .. :-)



-----Original Message-----
From: Andreas Andreou [mailto:[EMAIL PROTECTED] 
Sent: 30 June 2005 10:55
To: Tapestry users
Subject: Re: Generating a single Javascript function from multiple
components


>But is it possible to define a function such as
>
>Function enableAllComponents()
>{
>   // Components write Javascript here during rendering
>} 
>
>And then have a number of components write the Javascript to fill in the
>body of the single function. 
>
>Is this possible? 
>  
>

This is not supported by Tapestry itself, but there are ways to achieve 
this...
You could do the following:
1) surround your components with a new component, let's name it
JavascriptGatherer. This new component will provide a public method 
appendJS(String)
and will override setupComponent(IRequestCycle cycle) in order to place 
itself as an
attribute into the current cycle
2) The enclosed components will get a reference to JavascriptGatherer 
(from the cycle)
and call the appendJS method
3) Finally, the JavascriptGatherer will override
renderComponent(IMarkupWriter writer, IRequestCycle cycle)
and at first, it will call its parent's renderComponent (allowing nested 
components
to render themselves and contribute javascript).
It will then use the writer to output the javascript it has gathered!

You can also take a look at the source of MachoBar and MachoItem at
http://sourceforge.net/projects/tapfx/
(Browse CVS, package net.sf.tapfx.components.machobar)
They implement what I've described

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


Scanned for viruses by MessageLabs


Scanned for viruses by MessageLabs. The integrity and security of this message 
cannot be guaranteed. This email is intended for the named recipient only, and 
may contain confidential information and proprietary material. Any unauthorised 
use or disclosure is prohibited.

Reply via email to