To have a better controle on script you can implement like me your own DocumentScriptBuilderImpl
And override the existing with this code in your app module : public PageRenderInitializer buildMyPageRenderInitializer(final List<PageRenderCommand> configuration, final Environment environment) { return new PageRenderInitializer() { public void cleanup(MarkupWriter writer) { Iterator<PageRenderCommand> i = InternalUtils.reverseIterator(configuration); while (i.hasNext()) i.next().cleanup(environment); environment.clear(); } public void setup(MarkupWriter writer) { environment.clear(); environment.push(MarkupWriter.class, writer); environment.push(Document.class, writer.getDocument()); for (PageRenderCommand command : configuration) command.setup(environment); } }; } public void contributeMyPageRenderInitializer(OrderedConfiguration<PageRenderCommand> configuration, ThreadLocale threadLocale, @Path("org/apache/tapestry/default.css") Asset tapestry_css, @Path("my_own.css") Asset my_own_css, @Path("org/apache/tapestry/field-error-marker.png")Asset fieldErrorIcon, ValidationMessagesSource validationMessagesSource, final SymbolSource symbolSource, final AssetSource assetSource) { configuration.add("PageRenderSupport", new PageRenderCommand() { public void cleanup(Environment environment) { environment.pop(PageRenderSupport.class); Document document = environment.peek(Document.class); DocumentScriptBuilder builder = environment.pop( DocumentScriptBuilder.class); builder.updateDocument(document); } public void setup(Environment environment) { DocumentScriptBuilder builder = new MyOwnDocumentScriptBuilderImpl(); environment.push(DocumentScriptBuilder.class, builder); environment.push(PageRenderSupport.class, new PageRenderSupportImpl(builder, symbolSource, assetSource)); } }); configuration.add("Heartbeat", new PageRenderCommand() { public void cleanup(Environment environment) { environment.pop(Heartbeat.class).end(); } public void setup(Environment environment) { HeartbeatImpl heartbeat = new HeartbeatImpl(); heartbeat.begin(); environment.push(Heartbeat.class, heartbeat); } }); configuration.add("InjectTapestryStylesheet", new InjectStandardStylesheetCommand(tapestry_css)); configuration.add("InjectBaseStylesheet", new InjectStandardStylesheetCommand(my_own_css,)); configuration.add("DefaultValidationDelegate", new DefaultValidationDelegateCommand(threadLocale, validationMessagesSource, fieldErrorIcon)); } public static void contributeAliasOverrides(Configuration<AliasContribution> configuration, @InjectService("MyPageRenderInitializer")PageRenderInitializer pageRenderInitializer) { configuration.add(AliasContribution.create( PageRenderInitializer.class, pageRenderInitializer)); } And you can controle the script render like this (in your own DocumentScriptBuilderImpl) public void updateDocument(Document document) { Element head = document.find("html/head"); Element body = document.find("html/body"); if (head == null || body == null) return; for (int i = 0; i < scripts.size(); i++) { String scriptURL = scripts.get(i); head.elementAt(i, "script", "src", scriptURL, "type", "text/javascript"); } if (scriptBlock.length() > 0) { ... } On 7/17/07, Todd Orr <[EMAIL PROTECTED]> wrote:
Thanks! These both work, sort of. The renderSupport puts the script tag in the body tag (5.0.5). So, its not a huge improvement. While the more manual solution of adding the element works well enough, neither of these solutions easily allow arbitrary blocks to be inserted. I think this would be the holy grail of this situation. 1. Define a Block of code (declaratively in your template) 2. Insert Block into head With the Element and RenderSupport solutions I imagine the the plumbing exists to do this. I'll have to dig deeper into the how's to figure it out. Thanks again. On 7/17/07, David Avenante <[EMAIL PROTECTED]> wrote: > I think something like that work : > > @Environmental > private PageRenderSupport renderSupport; > > @Inject > @Path("myScript.js") > private Asset myScript; > > > renderSupport.addScriptLink(myScript); > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]