Hi! Thanks for your hints, nevertheless I'm afraid problem is not solved... I'm importing js file inside my component as you suggesting: @Import(stylesheet = "MyComponent.css", library="MyComponent.js") public class MyComponent {...}
Content of js is following: function setPosition() { // set of style changes } var db = function decorateBody() { document.body.setAttribute("onload","setPosition();"); document.body.setAttribute("onScroll","setPosition();"); } db(); What I get in browser is: 1. Uncaught TypeError: Cannot call method 'setAttribute' of null This leads me to thought that body element (I'm setting attributes on) is not existing yet. Am I missing something? I've tried to check other possibilities of javaScriptSupport, but nothing helped. Only working solution is to use addScript() as Dmitry suggested, I'm not very happy with storing flag in request solution, but it is currently best solution I have. Best regards Ladislav ---------- Původní zpráva ---------- Od: Thiago H de Paula Figueiredo <thiag...@gmail.com> Komu: Tapestry users <users@tapestry.apache.org> Datum: 19. 2. 2014 19:17:45 Předmět: Re: Executing JS function from component ONCE "On Wed, 19 Feb 2014 14:54:07 -0300, Dmitry Gusev <dmitry.gu...@gmail.com> wrote: > Another option could be to store some attribute in the request scope and > only call javaScriptSupport.addScript once on the server side. JavaScriptSupport.addSCript() is deprecated in T5.4. In addition, I've just noticed, he's doing a wrong thing anyway: the call to decorateBody() should be inside a .js file @Import'ed by the component. Tapestry only includes each imported .js file once, so decorateBody() will be called exactly once. Problem solved by doing the right thing. :) -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org"