You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Lewis <ch...@bellsouth.net> on 2007/08/13 23:51:39 UTC

T5: a layout with varying style sheets

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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: a layout with varying style sheets

Posted by Chris Lewis <ch...@bellsouth.net>.
Martin,

I've just looked at DocumentScriptBuilder, which seems to be a delegate 
of PageRenderSupport(Impl). I understand that PageRenderSupport uses a 
notification (cleanup i think) to know when to insert the scripts, but 
the way scripts are added (correct me if I'm wrong) are via explicit 
method calls as opposed to a declarative way. While this could work I'd 
prefer to just use implicit components in the template, and when the 
page is rendered, have a the component or another service handle 
appending to the <head>. Here's a test component method that I've hacked 
out that does the basics. Right now it just inserts a bogus link tag:

    @BeginRender
    void beginRender(MarkupWriter writer) {
        Element eHead = writer.getDocument().find("html/head");
        eHead.element("link", "rel", "stylesheet", "type", "text/css", 
"href", "test.css");
    }

I'm not sure how I feel about this. Obviously it doesn't address 
ordering, but it seems to be 'correct' other than that and the fact that 
I can't figure out how to close the <link> element (writer.end() throws 
exceptions). You seem to favor a service over a component - do mind 
explaining why?

Also, could you elaborate on 'peek' ing? I'm still new to Tapestry and 
I'm not completely aware of all the terms/architecture yet.

Thanks tons for your input.

chris

Martin Reurings wrote:
> Well, one could peek to get the markupwriter, but perhaps you may want 
> to dig through the sourcecode to see what Howard's done to support 
> adding javascript files on the fly. He uses a 'service' 
> DocumentScriptBuilder to 'declare' the various scripts as well as keep 
> them unique and then once all components have rendered he modifies the 
> DOM to prepend script tags to the body.
>
> I've been meaning to build a style version for a project we're doing 
> but just haven't found the time yet (it's not a critical issue as yet).
>
> The idea here would be:
> 1) create a 'service' to declare your stylesheets to. In essence any 
> List<String> that ensures unique entries and if desires order.
> 2) declare this service in your AppModule in such a way that it's 
> available to all pages
> 3) Using peek or peekrequired any component can declare stylesheets to 
> the service
> 4) On document cleanup add a link for each declared stylesheet to the 
> end of head-elememt (preserving order).
>
> I don't have the details of where to do step (4) yet, I haven't had 
> the need to find out but if you follow the trail of breadcrumbs and 
> hunt down DocumentScriptBuilder one would assume you'd be able to do 
> this :)
>
> Other than this alternative, I see nothing wrong with what you 
> proposed, except perhaps that it doesn't ensure uniqueness, which I 
> would find essential :)
>
> Good luck,
>
> Martin
>
> 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: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: a layout with varying style sheets

Posted by Martin Reurings <ma...@windgazer.nl>.
Well, one could peek to get the markupwriter, but perhaps you may want 
to dig through the sourcecode to see what Howard's done to support 
adding javascript files on the fly. He uses a 'service' 
DocumentScriptBuilder to 'declare' the various scripts as well as keep 
them unique and then once all components have rendered he modifies the 
DOM to prepend script tags to the body.

I've been meaning to build a style version for a project we're doing but 
just haven't found the time yet (it's not a critical issue as yet).

The idea here would be:
1) create a 'service' to declare your stylesheets to. In essence any 
List<String> that ensures unique entries and if desires order.
2) declare this service in your AppModule in such a way that it's 
available to all pages
3) Using peek or peekrequired any component can declare stylesheets to 
the service
4) On document cleanup add a link for each declared stylesheet to the 
end of head-elememt (preserving order).

I don't have the details of where to do step (4) yet, I haven't had the 
need to find out but if you follow the trail of breadcrumbs and hunt 
down DocumentScriptBuilder one would assume you'd be able to do this :)

Other than this alternative, I see nothing wrong with what you proposed, 
except perhaps that it doesn't ensure uniqueness, which I would find 
essential :)

Good luck,

 Martin

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: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: a layout with varying style sheets

Posted by Chris Lewis <ch...@bellsouth.net>.
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: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


Re: T5: a layout with varying style sheets

Posted by Chris Lewis <ch...@bellsouth.net>.
I have some thoughts on ordering, but first could you elaborate on, or 
better yet point me to documentation on teh Environmental service? I've 
seen it mentioned but know nothing about it.

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: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: a layout with varying style sheets

Posted by Robert Zeigler <ro...@scazdl.org>.
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: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: a layout with varying style sheets

Posted by Chris Lewis <ch...@bellsouth.net>.
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: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: a layout with varying style sheets

Posted by Robert Zeigler <ro...@scazdl.org>.
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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org