This is quite possible in Tapestry today. A Script Specification (a ".script" file) can <include- script> a JavaScript library (a ".js" file).
The library is located on the classpath. A library is only included on a page once, regardless of how many times it is referenced. The Script Specification can reference variables and functions in the library. The Palette component is an example of this; it has a Palette.js that includes lots of variables and functions. Palette.script includes this and builds additional event handling methods and the like, on top of the library. The next release of Tapestry may include an easy way to create "once only" blocks directly in the Script Specficiation. -- [EMAIL PROTECTED] http://tapestry.sf.net > Hello, > > Perhaps the subject is not correct, so I try to > explain what I need. > Consider that I have a Tapestry component > A. I expect to have multiple instances of this > component on a page (instantiated in different > places). > > This component needs some javascript to support it. > The javascript side consists of few global > library methods shared by all instances > of component, BUT called with different sets of > parameters by different instances of component A. > > (1) I want to be able to attach a script to > my component in such a way that "library" > javascript > methods are created only once per page regardless > of how many instances of component I am creating. > > (2) I realize that I could define a separate script > component on the page with all my global functions. > Nevertheless it has a problem that I should > always remember to append this script component > whenever I am using component A on any given page and > remove it whenever I do not need it anymore. Also > it will cause problems if I nest component A inside > other components, etc. > > I cannot see a simple way to do it presently - > correct me if I am wrong. > > I believe it should be simple to implement in > Tapestry. Basically one has to be able to define > a singleton script - inserted into any given page > only once regardless of how many times script tag > is used in nested components. What about > adding an extra parameter to the script component? > > Parameter = singleton > Type = boolean > Required = no > > I know that this is what image preload is doing > presently, but I believe it is an internal feature > of Tapestry rather then component. > > Cheers, > Toly > > __________________________________________________ > Do You Yahoo!? > Everything you'll ever need on one web page > from News and Sport to Email and Music Charts > http://uk.my.yahoo.com > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Tapestry-developer mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/tapestry-developer ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Tapestry-developer mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/tapestry-developer
