I agree that under normal circumstances the layout component should
override styles in the embedded component, except in the cases (such as
this example) where the embedded component represents a page. We /want/
the page to be able to have the ability to override styles in the
"general" containing styles of the layout. This isn't the same situation
as using some 3rd party component and needing to override those styles,
but the problem is that Tapestry sees them as the same.
Robert Zeigler wrote:
Overall, that looks pretty good, but you could handle it easier, I
think, by using the environment service.
The top level document is available during render from the Environment
service, so you could use that in place of steps 2 and 3.
Consistent ordering would be nice... the difficult thing there is
determining what ordering should be the correct ordering.
If you have some way or knowing what the correct ordering ought to be,
then you could certainly traverse the dom and make sure your new link
element is inserted in the correct location.
But the real question is knowing what the right order should be. Order
of render is probably incorrect. For example, you create a "layout"
component which inserts your application-specific stylesheets via the
proposed custom style component. Your layout is embedded in a page,
and as part of the layout body, there is a component which also uses
the style component. Rendering order would place the style of the
layout first, and the style of the embedded component second, which is
probably not what you want since you might be overriding the
component-default styling in your application style. (You could get
around that be declaring your layout/application-specific style
component after the <t:body/> of your layout component, but...) You
don't want to have to explicitly define an order in the style
component since you don't really know what stylesheets will be
available. But, again, if you can figure out what the order /ought/
to be, you should be able to enforce that order. :)
Robert
On Aug 13, 2007, at 8/136:08 PM , Chris Lewis wrote:
So it looks like one would need to (re)create something similar to
the T4 Shell component.
I've taken a brief look at the DOM api, and if I were to write
something as focused as a Style component, then it looks like I'd
have to:
1) create my component class, either in my.namespace.components, or
another module that is loaded and contributed
2) get a MarkupWriter instance via void beginRender/@BeginRender
3) use writer.getRootElement() to get the root, and then traverse
into the <head>
4) assuming eHead is my <head> Element, use eHead.element("link",
"rel", "stylesheet", "type", "text/css", "href",
"TODO-css-url-here"), to append a <link>
Can anyone comment on the (in)correctness of this?
It'd be nice to ensure ordering of the sheets somehow, so they can
cascade properly. It'd be easier to do that with a more sophisticated
Shell-link component that handled building the page base (head,
metas, scripts, etc). Anyway, please share thoughts.
thanks
chris
Robert Zeigler wrote:
T5 renders with a dom.
Gives you a lot of control...
You could create a "style" component that finds the head and inserts
the appropriate <link> element.
Then your components could add their own stylesheets using the style
component, with the page and containing components none the wiser.
You would want to make sure that a given stylesheet is inserted only
once, of course (eg, if your component is contained within a loop...).
A component like this should be very straightforward to write in T5.
Robert
On Aug 13, 2007, at 8/134:51 PM , Chris Lewis wrote:
One of the nice things I learned in my brief investigation of
T4.1.2 was that the Shell component would automatically pick up any
style sheets a page declared using the @Style annotation (or
something like that). I've been wondering how something like this
might be achieved in T5, using the available components as opposed
to subclassing a base page. This seems like a feature that would be
part of the core, as it is such a common need.
I know I could emulate this by creating a layout that expected a
page property, say externalCss (a collection), and using the Loop
component to iterate it and insert the link elements. Is this the
only way to do this in T5?
thanks!
chris
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
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]