views:

182

answers:

2

Hi all,

Is it possible to use a @Script component to render a script tag pointing to a js file hosted on a different server?

Basically, I need to inject a script tag such as:

<script src="http://otherserver.com/script.js"&gt;&lt;/script&gt;

but I need to have it render in the head, or at least before other tapestry scripts are rendered.

Thanks, Paul.

+1  A: 

If you're using the Shell component , it's easy:

Shell.get(cycle).includeAdditionalContent( myHtmlForHead );

Or write a simple component that does that and reuse it in your templates.

Andreas Andreou
+1  A: 

Assuming you're using a Shell component to wrap all your other files:

<html jwcid="@Shell" delegate="ognl:new org.apache.tapestry.components.BlockRenderer(getComponent('scriptBlock'))">

  <span jwcid="scriptBlock@Block">
    <script src="http://otherserver.com/script.js"&gt;&lt;/script&gt;
  </span>

  ...

</html>
Civil Disobedient