I agree that tapestry could be a bit smarter when components/layouts extend
each other. This improvement could be made without adding a priority/order
to the @Import annotation. I think this is worthy of a Jira issue.

As I mentioned before, adding a priority/order to the @Import annotation
could have issues when stacks are used or when two @Imports for the same
asset have a different order/priority. I think this requires a bit more
thought.

On Tuesday, 20 March 2012, Beat Durrer <bdur...@gmail.com> wrote:
> I did some tests and the order of the stylesheets is actually reversed
> to what I expected it to be...
>
> Here is an example:
>
> Let's say we define a RootLayout, which has all the basics ( <html>
> tag, meta stuff, the <body> tag).
> Then we have a SimpleLayout which uses the RootLayout but adds a top
> navigation to it.
> Next is a TwoColumnLayout which uses the SimpleLayout and introduces
> two columns ( t:body and a t:delegate for the sidebar, as in the T5
> archetype)
> Then we have some SpecialCaseLayout which uses the TwoColumn, but does
> some specific magic and overrides some CSS and adds some elements.
>
> All those components have an own, specific @import stylesheet.
>
> What I would expect is that the CSS come in this order: RootLayout,
> SimpleLayout, TwoColumnLayout, SpecialCaseLayout.
> That way you would be able to override whatever you need in your
> SpecialCaseLayout
>
> Currently T5.3.2 renders in the opposite order.
> Would be nice to have an order parameter, similar to ordered
> configurations (like "after:TwoColumnLayout.css")
>
>
>
> 2012/3/20 Lance Java <lance.j...@googlemail.com>:
>> For each component, Tapestry includes the stylesheets and javascript for
>> each making sure to only include each unique file once. I'm not 100% but
I
>> guess that the order in which the components appear in the page probably
>> defines the order in which they appear in the page.
>>
>> What would be nice is if you could contribute a preferred order for
>> @Includes to JavaScriptSupport although I have no idea how this would
work
>> when stacks are used. Looking through TapestryModule it doesn't look very
>> easy to override JavaScriptSupportImpl without copy/pasting quite a bit
of
>> code. I would stick with a MarkupRendererFilter for now.
>>
>> Another option would be to include a priority in the @Import annotation.
>> Again, I'm not sure this would work with stacks or what would happen for
>> two @Imports for the same asset with different priorities.
>>
>> As you said, you could handle stylesheets yourself. Probably by including
>> all stylesheets in your Layout component and avoid using @Import
>> annotations.
>>
>> On Tuesday, 20 March 2012, Beat Durrer <bdur...@gmail.com> wrote:
>>> Thanks for your help Lance, I'm sure it could work that way.
>>>
>>> I am a bit suprised that there is no direct solution to this. It's
>>> common to have some libraries or default CSS and override them on
>>> specific pages / layouts.
>>> Making CSS special cases or writing an own MarkupRendererFilter for an
>>> issue that could be solved by placing the CSS links in the correct
>>> order seems like a big overkill to me.
>>>
>>> I rather go back to writing the CSS include myself than jumping through
>> hoops.
>>>
>>>
>>>
>>>
>>> 2012/3/19 Lance Java <lance.j...@googlemail.com>:
>>>> In your AppModule, you can contribute a MarkupRendererFilter to fire
>> after
>>>> JavaScriptSupport
>>>>
>>>>    public void
>>>> contributeMarkupRenderer(OrderedConfiguration<MarkupRendererFilter>
>>>> configuration) {
>>>>        configuration.addInstance("MyMarkupRendererFilter",
>>>> MyMarkupRendererFilter.class, "after:JavaScriptSupport");
>>>>    }
>>>>
>>>> MyMarkupRendererFilter can use then manipulate the MarkupWriter's DOM
>>>> before it is written to the response output stream
>>>>
>>>>
>>
http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/MarkupWriter.html
>>>>
>>>> On Monday, 19 March 2012, Beat Durrer <bdur...@gmail.com> wrote:
>>>>> Hi all,
>>>>>
>>>>> I have a "RootLayout" component which loads a CSS file, and some
>>>>> SubLayout components add an other CSS.
>>>>> I'm using T5.3.2 and simply applied the @Import(stylesheet={...}) to
>>>>> the Layout classes.
>>>>>
>>>>> At the moment, the CSS from RootLayout is loaded after the SubLayouts
>>>>> and therefore overrides theCSS styles.
>>>>> Can I somehow control in which order those stylesheets are loaded?
How?
>>>>>
>>>>>
>>>>> Thanks in advance :-)
>>>>> Beat
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>>>
>>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apach

Reply via email to