Thanks for your answer! Le 23 juin 2014 à 16:17, Thiago H de Paula Figueiredo <thiag...@gmail.com> a écrit :
> On Mon, 23 Jun 2014 10:53:38 -0300, Numa Schmeder <n...@dfacto.ch> wrote: > >> Hello, > > Hi! > >> I am using Tapestry 5.4 beta 6. >> I am trying to add a script block at the very end of the page body, after >> tapestry has written all its javascript. >> I know there are 2 ways: using javascriptSupport.addScript or >> javascriptSupport.require or creating one js file par page and load it via >> AMD. > > You forgot about creating one .js file and using @Import. Yes that’s what I was meaning with one js file per page, you need to use the @Import. But I have a special use case where all js is not in the context but on separate server. And the @Import makes things a bit complicated. Would be nice to have @Import working with absolute path or have a special @ImportUrl > >> But i want it to output a simple raw javascript block at the very end of the >> page. >> I tried to create a component “Javascript” to do just that, but I can’t >> figure how to render at the very end of the page after all other javascript. >> The reason is that sometimes outputting a block in the main page is simpler >> than to create one js file per page and then to require it. > > It may be simpler, but it doesn't pay off in the end. In addition, you don't > need to create one .js file for each page: you can create a single one > containing all the JS code you want and @Import it everywhere you need it. > Tapestry will only include it once, no matter how many components @Import it. That’s true, but I like to break my js on each page instead of having one big js, but you are absolutely right. The thing is that when prototyping quickly, the ability to inline javascript is very useful. Once you are happy with your prototype you can do some cleaning and organize your js better. > >> Also the javaScriptSupport.addScript method is deprecated, the >> javaScriptSupport.require should be used, but it does not the same. >> What is the equivalent of addScript in Tapestry5.4 > > There's none, exactly because adding raw JavaScript in Java isn't the best > option. Well actually we can use the documentLink.addScript, this one is not yet deprecated… > >> Is there a way to bypass pageinit to initialize or add scripts and have them >> at the end of the page ? > > You can write and contribute a MarkupRendererFilter, but then it's not a > component anymore. This sounds over complicated and as you said it’s not a component anymore. Based on the initial work of Adam Henderson https://github.com/adamhenderson/tapestry-dojo. I have fully ported the dojo stack to tapestry. All core components do work (forms, ajax, zones, confirm, autocomplete etc…) I have kept only the underscore library dependency, though I could get rid of it, as most underscore functions are available within dojo. I will release all the changes in one jar and put on github. I am just having some difficulties with the @Symbol usage. The dojoConfig javascript object is created by contributing specific symbols. But some config properties of dojoConfig are optional, and if I set a Symbol to null, I get an exception. So the workaround is to set all my symbols to strings, and an empty string value means don’t set this property. I don’t know if there is a better way. Also dojo amd loader doesn’t provide the ability to shim non amd libraries and have init calls per file load. I am still figuring out how it works with tapestry module dependency amd and loading, it’s not completely clear. While doing all this work I have notice a weird behavior that is reproducible with the jquery stack. When you update a zone or refresh it. The divs start to nest on inside each other. Exemple: <div id=“zone"> My initial zone </div> After 2 updates, the zone content becomes: <div id=“zone"> <div id=“zone_84847657567"> <div id=“zone_874747899884"> My initial zone after 2 updates </div> </div> </div> I would have thought that should replace the content and have the following html: <div id=“zone"> My initial zone after 2 updates </div> > > -- > 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 > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org