Just use RenderSupport.
I just built my own component named asset attacher for this purpose.
public class AssetAttacher
{
@Parameter(required = true, allowNull = false, defaultPrefix =
BindingConstants.LITERAL)
private String assetURL;
@Parameter(required = true, allowNull = false, defaultPrefix =
BindingConstants.LITERAL)
private String assetType;
@Inject
private EnvironmentAssetAliasManager assetAliasManager;
@Environmental
private RenderSupport renderSupport;
@SetupRender
public boolean attach()
{
if (assetType.equalsIgnoreCase("javascript"))
{
renderSupport.addScriptLink(assetURL);
}
else
{
renderSupport.addStylesheetLink(assetURL, null);
}
// short circuit to prevent rendering of body (since there's no tml for
this component)
return false;
}
}
Then from other components tml, just include the AssetAttacher.
<t:AssetAttacher t:assetURL="http://www.differentsite.com/my.css"
t:assetType="stylesheet"/>
or
<t:AssetAttacher t:assetURL="http://www.differentsite.com/my.js"
t:assetType="javascript
"/>
----- Original Message ----
From: Geoffrey Wiseman <[email protected]>
To: Tapestry users <[email protected]>
Sent: Thursday, March 26, 2009 1:05:52 PM
Subject: Re: @IncludeStylesheet and non-local CSS
On Thu, Mar 26, 2009 at 12:47 PM, Geoffrey Wiseman <
[email protected]> wrote:
> If I were to build component that uses YUI, and I wanted to attach the
> stylesheet from Yahoo (rather than copying it to my application), it doesn't
> seem as if @IncludeStylesheet will let me do that; am I correct?
>
This was raised before for Javascript (
http://markmail.org/thread/pcrp6gzkyvsm37i5) -- while rendering the
Javascript right in the body of the page seems like not a big deal, it's not
really ideal for CSS, and it doesn't buy you the duplicate-detection that
@IncludeStylesheet will. If it's possible to use external paths, even if it
means I have to do some plumbing, I'd like to know about it.
Looks like it /might/ be able to do this with my own asset factory?
- Geoffrey
--
Geoffrey Wiseman
http://www.geoffreywiseman.ca/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]