You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alec Swan <al...@gmail.com> on 2011/04/24 00:05:57 UTC

Forcing parent CSS to be contributed after all child CSS

Hello,

I have a component tree where some components contribute CSS. I have
inline CSS for the parent component that should be contributed last in
order to override CSS of child components.

Children components contribute their CSS in their constructors using
add(new StyleSheetReference("cssId", getClass(), "/css/styles.css")).
I have to use this approach because other approaches don't work with
panel swapping (I have yet to create a JIRA issue for this).

The parent component is contributing CSS by calling
response.renderString("body {background-color:red}") from
IHeaderContributor#renderHead(IHeaderResponse).

I tried contributing parent CSS in parents onInitialize() and
onBeforeRender(), but children's CSS always get written last.

Is there any way to force parent's CSS to be contributed last?

Thanks,

Alec

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


Re: Forcing parent CSS to be contributed after all child CSS

Posted by Pedro Santos <pe...@gmail.com>.
See if you can implement your contribution sequence rule by decorating the
IHeaderResponse e.g. [1] [2]

1 -
http://grepcode.com/file/repo1.maven.org/maven2/org.apache.wicket/wicket-examples/1.5-rc2/org/apache/wicket/examples/resourcedecoration/ResourceDecorationApplication.java?av=f
2 - http://wicketstuff.org/wicket/resourceaggregation


On Tue, Apr 26, 2011 at 7:05 PM, Alec Swan <al...@gmail.com> wrote:

> Even though using very specific CSS selectors works it makes it a lot
> harder to write that CSS.
>
> Is there a way to force Wicket to write parent CSS contribution after
> the children's CSS contribution?
>
> Thanks,
>
> Alec
>
> On Sat, Apr 23, 2011 at 8:06 PM, Alec Swan <al...@gmail.com> wrote:
> > Thanks for the ideas, Clint. The child components do not know about
> > parent CSS, so I decided to use more specific CSS selectors in the
> > parent CSS to accomplish what I needed.
> >
> > Alec
> >
> > On Sat, Apr 23, 2011 at 4:35 PM, Clint Checketts <ch...@gmail.com>
> wrote:
> >> I recall reading an article once noting that you could contribute the
> CSS
> >> file noted in the parent class again in the child component and Wicket
> is
> >> smart enough to not duplicate the contribution, but it still forces the
> CSS
> >> file to appear later.
> >>
> >> You also may consider changing the parent CSS rules to be more specific
> or
> >> generic (depending on your intentions), to allow them to cascade.
> >>
> >> -Clint
> >>
> >> On Sat, Apr 23, 2011 at 5:05 PM, Alec Swan <al...@gmail.com> wrote:
> >>
> >>> Hello,
> >>>
> >>> I have a component tree where some components contribute CSS. I have
> >>> inline CSS for the parent component that should be contributed last in
> >>> order to override CSS of child components.
> >>>
> >>> Children components contribute their CSS in their constructors using
> >>> add(new StyleSheetReference("cssId", getClass(), "/css/styles.css")).
> >>> I have to use this approach because other approaches don't work with
> >>> panel swapping (I have yet to create a JIRA issue for this).
> >>>
> >>> The parent component is contributing CSS by calling
> >>> response.renderString("body {background-color:red}") from
> >>> IHeaderContributor#renderHead(IHeaderResponse).
> >>>
> >>> I tried contributing parent CSS in parents onInitialize() and
> >>> onBeforeRender(), but children's CSS always get written last.
> >>>
> >>> Is there any way to force parent's CSS to be contributed last?
> >>>
> >>> Thanks,
> >>>
> >>> Alec
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>
> >>>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Pedro Henrique Oliveira dos Santos

Re: Forcing parent CSS to be contributed after all child CSS

Posted by Alec Swan <al...@gmail.com>.
Even though using very specific CSS selectors works it makes it a lot
harder to write that CSS.

Is there a way to force Wicket to write parent CSS contribution after
the children's CSS contribution?

Thanks,

Alec

On Sat, Apr 23, 2011 at 8:06 PM, Alec Swan <al...@gmail.com> wrote:
> Thanks for the ideas, Clint. The child components do not know about
> parent CSS, so I decided to use more specific CSS selectors in the
> parent CSS to accomplish what I needed.
>
> Alec
>
> On Sat, Apr 23, 2011 at 4:35 PM, Clint Checketts <ch...@gmail.com> wrote:
>> I recall reading an article once noting that you could contribute the CSS
>> file noted in the parent class again in the child component and Wicket is
>> smart enough to not duplicate the contribution, but it still forces the CSS
>> file to appear later.
>>
>> You also may consider changing the parent CSS rules to be more specific or
>> generic (depending on your intentions), to allow them to cascade.
>>
>> -Clint
>>
>> On Sat, Apr 23, 2011 at 5:05 PM, Alec Swan <al...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I have a component tree where some components contribute CSS. I have
>>> inline CSS for the parent component that should be contributed last in
>>> order to override CSS of child components.
>>>
>>> Children components contribute their CSS in their constructors using
>>> add(new StyleSheetReference("cssId", getClass(), "/css/styles.css")).
>>> I have to use this approach because other approaches don't work with
>>> panel swapping (I have yet to create a JIRA issue for this).
>>>
>>> The parent component is contributing CSS by calling
>>> response.renderString("body {background-color:red}") from
>>> IHeaderContributor#renderHead(IHeaderResponse).
>>>
>>> I tried contributing parent CSS in parents onInitialize() and
>>> onBeforeRender(), but children's CSS always get written last.
>>>
>>> Is there any way to force parent's CSS to be contributed last?
>>>
>>> Thanks,
>>>
>>> Alec
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>

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


Re: Forcing parent CSS to be contributed after all child CSS

Posted by Alec Swan <al...@gmail.com>.
Thanks for the ideas, Clint. The child components do not know about
parent CSS, so I decided to use more specific CSS selectors in the
parent CSS to accomplish what I needed.

Alec

On Sat, Apr 23, 2011 at 4:35 PM, Clint Checketts <ch...@gmail.com> wrote:
> I recall reading an article once noting that you could contribute the CSS
> file noted in the parent class again in the child component and Wicket is
> smart enough to not duplicate the contribution, but it still forces the CSS
> file to appear later.
>
> You also may consider changing the parent CSS rules to be more specific or
> generic (depending on your intentions), to allow them to cascade.
>
> -Clint
>
> On Sat, Apr 23, 2011 at 5:05 PM, Alec Swan <al...@gmail.com> wrote:
>
>> Hello,
>>
>> I have a component tree where some components contribute CSS. I have
>> inline CSS for the parent component that should be contributed last in
>> order to override CSS of child components.
>>
>> Children components contribute their CSS in their constructors using
>> add(new StyleSheetReference("cssId", getClass(), "/css/styles.css")).
>> I have to use this approach because other approaches don't work with
>> panel swapping (I have yet to create a JIRA issue for this).
>>
>> The parent component is contributing CSS by calling
>> response.renderString("body {background-color:red}") from
>> IHeaderContributor#renderHead(IHeaderResponse).
>>
>> I tried contributing parent CSS in parents onInitialize() and
>> onBeforeRender(), but children's CSS always get written last.
>>
>> Is there any way to force parent's CSS to be contributed last?
>>
>> Thanks,
>>
>> Alec
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

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


Re: Forcing parent CSS to be contributed after all child CSS

Posted by Clint Checketts <ch...@gmail.com>.
I recall reading an article once noting that you could contribute the CSS
file noted in the parent class again in the child component and Wicket is
smart enough to not duplicate the contribution, but it still forces the CSS
file to appear later.

You also may consider changing the parent CSS rules to be more specific or
generic (depending on your intentions), to allow them to cascade.

-Clint

On Sat, Apr 23, 2011 at 5:05 PM, Alec Swan <al...@gmail.com> wrote:

> Hello,
>
> I have a component tree where some components contribute CSS. I have
> inline CSS for the parent component that should be contributed last in
> order to override CSS of child components.
>
> Children components contribute their CSS in their constructors using
> add(new StyleSheetReference("cssId", getClass(), "/css/styles.css")).
> I have to use this approach because other approaches don't work with
> panel swapping (I have yet to create a JIRA issue for this).
>
> The parent component is contributing CSS by calling
> response.renderString("body {background-color:red}") from
> IHeaderContributor#renderHead(IHeaderResponse).
>
> I tried contributing parent CSS in parents onInitialize() and
> onBeforeRender(), but children's CSS always get written last.
>
> Is there any way to force parent's CSS to be contributed last?
>
> Thanks,
>
> Alec
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>