You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by WarnerJan Veldhuis <wa...@qprcostcontrol.com> on 2009/06/26 09:42:23 UTC

Order of CCS imports

Hello,

I want to override some styles of click.css, but not ALL of them.
Problem here is that the click.css import comes last in the imports, so
there is no way to override a single click-generated-style. 

Alternatively I can copy the existing click.css and supply my own
click.css, but I was wondering if I had any influence over the order of
CSS import lines.

Cheers,

WarnerJan Veldhuis


Re: Order of CCS imports

Posted by Malcolm Edgar <ma...@gmail.com>.
I think with the Page elements support now PageImports should be depreciated.

As the PageImports method was a fairly recent addition we could also
look at the option of removing this from the Page.

regards Malcolm Edgar

On Sat, Jun 27, 2009 at 2:00 AM, Bob Schellink<sa...@gmail.com> wrote:
> WarnerJan Veldhuis wrote:
>>
>> Ah, here's what went wrong: in the onInit() of the BorderPage, I had the
>> line getPageImports().add( new CssImport(...) ). It works, but has a
>> side effect on the order of the import. When I override
>> getHeadElements() it works fine: my css imports come last now.
>
>
> You can also use getHeadElements from onInit:
>
>  public void onInit() {
>    getHeadElements().add(...);
>  }
>
> However check the Javadoc as there is a caveat if you are using stateful
> pages.
>
> The only real use case for using getPageImports is if you want to merge all
> the Page imports into a single file for faster download. One would then set
> the PageImports "initialized" property to true so that no other imports are
> included. See this example:
> http://www.avoka.com/click-examples/general/page-imports-example.htm
>
> It might have been a mistake to expose getPageImports on Page as it will
> create confusion on how to import JS and CSS resources.
>
> bob
>

Re: Order of CCS imports

Posted by Bob Schellink <sa...@gmail.com>.
WarnerJan Veldhuis wrote:
> Ah, here's what went wrong: in the onInit() of the BorderPage, I had the
> line getPageImports().add( new CssImport(...) ). It works, but has a
> side effect on the order of the import. When I override
> getHeadElements() it works fine: my css imports come last now.


You can also use getHeadElements from onInit:

   public void onInit() {
     getHeadElements().add(...);
   }

However check the Javadoc as there is a caveat if you are using 
stateful pages.

The only real use case for using getPageImports is if you want to 
merge all the Page imports into a single file for faster download. One 
would then set the PageImports "initialized" property to true so that 
no other imports are included. See this example: 
http://www.avoka.com/click-examples/general/page-imports-example.htm

It might have been a mistake to expose getPageImports on Page as it 
will create confusion on how to import JS and CSS resources.

bob

Re: Order of CCS imports

Posted by WarnerJan Veldhuis <wa...@qprcostcontrol.com>.
Ah, here's what went wrong: in the onInit() of the BorderPage, I had the
line getPageImports().add( new CssImport(...) ). It works, but has a
side effect on the order of the import. When I override
getHeadElements() it works fine: my css imports come last now.

Cheers,

WarnerJan



On Fri, 2009-06-26 at 12:04 +0200, Bob Schellink wrote:
> Hi WarnerJan,
> 
> On 6/26/09, WarnerJan Veldhuis <wa...@qprcostcontrol.com> wrote:
> >
> > I want to override some styles of click.css, but not ALL of them.
> > Problem here is that the click.css import comes last in the imports, so
> > there is no way to override a single click-generated-style.
> >
> > Alternatively I can copy the existing click.css and supply my own
> > click.css, but I was wondering if I had any influence over the order of
> > CSS import lines.
> 
> 
> The order of the imports are the same order in which controls are
> added to the Page.
> 
> So if you have:
> 
>   addControl(form);
>   addControl(table);
> 
> the form imports will come before the table imports.
> 
> However Pages can have import statements too, which is included after
> the control imports.
> 
> So you could have:
> 
>   pubilc MyPage extends Page {
>     public void onInit() {
>       addControl(form);
>     }
> 
>     public String getHtmlImports() {
>       return "<style rel='stylesheet' type='text/css' href='/my-page.css'/>";
>     }
>   }
> 
> kind regards
> 
> bob


Re: Order of CCS imports

Posted by Bob Schellink <sa...@gmail.com>.
Hi WarnerJan,

On 6/26/09, WarnerJan Veldhuis <wa...@qprcostcontrol.com> wrote:
>
> I want to override some styles of click.css, but not ALL of them.
> Problem here is that the click.css import comes last in the imports, so
> there is no way to override a single click-generated-style.
>
> Alternatively I can copy the existing click.css and supply my own
> click.css, but I was wondering if I had any influence over the order of
> CSS import lines.


The order of the imports are the same order in which controls are
added to the Page.

So if you have:

  addControl(form);
  addControl(table);

the form imports will come before the table imports.

However Pages can have import statements too, which is included after
the control imports.

So you could have:

  pubilc MyPage extends Page {
    public void onInit() {
      addControl(form);
    }

    public String getHtmlImports() {
      return "<style rel='stylesheet' type='text/css' href='/my-page.css'/>";
    }
  }

kind regards

bob

Re: Order of CCS imports

Posted by WarnerJan Veldhuis <wa...@qprcostcontrol.com>.
Replace click.css with control.css. The question remains the same
though :)


On Fri, 2009-06-26 at 09:42 +0200, WarnerJan Veldhuis wrote:
> Hello,
> 
> I want to override some styles of click.css, but not ALL of them.
> Problem here is that the click.css import comes last in the imports, so
> there is no way to override a single click-generated-style. 
> 
> Alternatively I can copy the existing click.css and supply my own
> click.css, but I was wondering if I had any influence over the order of
> CSS import lines.
> 
> Cheers,
> 
> WarnerJan Veldhuis