Hello Howard, Great thanks - works very nicely. On further consideration, using JS libraries the way you proposed is a better way to handle big static pieces of Javascript instead of embedding it into pages - for one thing your browser makes the caching for you.
Two comments: 1) Include explicit mention of the way <include-script> into documentation - presently it is not clear if it references JS file or embeds it. Or perhaps describe it as a pattern in developer guide. I missed it, so might others. 2) I would greatly appreciate if you could include an "easy way to create "once only" blocks directly in the Script Specifciation" in some future release as you described. Right now, my javascript is pretty much "static-methods only" and I have to create two files always one of which is a script config with a single <include-script>. This arrangement is slightly unweildly. Cheers, Toly > 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 __________________________________________________ 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
