Hi John,

I don't know if this is kosher, but what I have on occasion done is
something like this:

<link jwcid="@Any" rel="stylesheet" href="asset:css.buildURL()"
type="text/css"></link>

I also used a variant with javascript to check if the stylesheet had
already been added (just add an id to the link).

Hope that helps

Best wishes

John 

-----Original Message-----
From: John Hendrikx [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 14, 2006 5:20 PM
To: Tapestry users
Subject: Component with Stylesheet asset... how?

I'm building my first Tapestry Component and I'm trying to encapsulate 
some common HTML components for my applications into a Tapestry 
Component.  The component also needs a few styles to look and function 
properly, and I'd like these styles to be included on the page whenever 
the component is used automatically (just like the javascript which is 
included automatically when I use my component).

The component so far works great, but I cannot seem to also make it 
include a stylesheet.

On the Tapestry site I found this:

 > Often, a component must be packaged up with images, stylesheets or
 > other resources (collectively termed "assets") that are needed at
 > runtime. A reference to such an asset can be created using the
<asset>
 > element of the page or component specification. For example:
 >      
 >  <asset name="logo" path="images/logo_200.png"/>
 >
 >  <component id="image" type="Image">
 >    <binding name="image" value="asset:logo"/>
 >  </component>

However, I cannot figure out how to "package stylesheets" with my 
component.  I've tried the following:

   <asset name="css" path="MenuPicker.css"/>

   <component id="stylesheet" type="Any">
     <binding name="stylesheet" value="asset:css"/>
   </component>

This however doesn't do anything, I get no errors, and I see no changes.

   For one thing, I'm not sure what the "type" parameter should be for 
including a stylesheet.  I don't see any Stylesheet or CSS component, 
like there is for Image.

I've checked the tapestry site, googled, and looked at the last few 
months of posts on this mailinglist, but I couldn't find anything that 
sheds light on this.  I'd be grateful for a pointer in the right 
direction :)

Here's the full component specification I'm using:

<component-specification 
class="com.bmw.tapestry.components.menupicker.MenuPicker"
allow-body="no">

   <parameter name="displayName"/>
   <parameter name="id" property="idParameter" default-value="id"/>
                
   <inject property="script" type="script" object="MenuPicker.script"/>

   <asset name="css" path="MenuPicker.css"/>

   <component id="stylesheet" type="Any">
     <binding name="stylesheet" value="asset:css"/>
   </component>
</component-specification>

The files are all in the same package 
(com.bmw.tapestry.components.menupicker); MenuPicker.java, jwc, 
properties, css, script and js

Any ideas?

--John

---------------------------------------------------------------------
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]

Reply via email to