Hello Todd,

I'm curious if you've made any progress on this as I too am interested in a declarative way to insert JS and CSS. The best thing I've come up with is a general component used for inserting elements into the head of the document. It could be used like this:

<t:pageresource type="style" src="TODO"/>

It may make sense to have components specifically for CSS and JS. This method is ok for me except for one issue - getting the assets into the src attribute. I *do not* want to have to create boilerplate accessors and inject the needed assets into my page/component classes, just so my template can reference them!

I'm sure you've seen this, but T5 uses InjectStandardStylesheetCommand to assure that the default style sheet always ends up in the document head. I don't think we can use this directly as I don't know that you can attach render commands to specific pages.

One idea that occurred to me is to create a service that does some final render tinkering, perhaps based on the presence of an annotation (like @Style or @Script). Of course this isn't at all declarative, but at least one wouldn't have to provide page members/accessors for injecting the assets and then accessing them.

Any thoughts?

Todd Orr wrote:
I'm trying to create a component that will allow me to define blocks
of HTML to insert into the head. I think this would be useful for ad
hoc JS, style declarations, etc. I know that this can be inserted
using other mechanisms like:

Element head = writer.getDocument().find("html/head");

and inserting your element manually, but this isn't pretty or
easy/possible for the script or style tag contents.

I know that an alternative is just to slap it in the page where the
component is rendered, but that's just sloppy.

On 9/11/07, Howard Lewis Ship <[EMAIL PROTECTED]> wrote:
It's somewhat impossible.  The content isn't stored as a string, but as a
large collection of objects representing different parts of the template as
well as components.  You're better off explaining what you want to do if you
want to avoid a blind alley.

It's a bit easier to get the renderered HTML after a component has rendered.

On 9/11/07, Todd Orr <[EMAIL PROTECTED]> wrote:
I've been pulling my hair out over this problem. How do simply get the
content of a component?

usage given:

<t:comp>
    <p>Some content</p>
</t:comp>

I have found that it's quite impossible to get the content into a
variable from within the component events.

Any ideas?

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to