You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Apple Grew <ap...@gmail.com> on 2010/04/09 19:07:47 UTC

Picking different CSS for different styles.

Hi All,

I am trying to create a themable wicket application which has one html per
page but different CSS files to change its looks. The CSS files are
referenced in the <head> of the html. The CSS files have been named as -
<theme_name>-all.css. I am very well able to dynamically generate the CSS
urls based on the theme name. The theme names are fetched from session, as,
MySession.getThemeName().

My concern is, that Wicket might cache the generated html file. So even if
the theme changes at runtime, the html with old CSS names will be served.
Furthermore, each user can have different themes, but here we have only
html.

If my understanding is correct then I should set the style to the theme
name. I read somewhere that Wicket generates keys to reference the cached
resources. So, I am guessing, that user A tries to access Home.html with
'classic' style then Wicket will render and cache that page as (say)
classic-Home. Now, if user B tries to access the same page but with style
'jazzy' then Wicket will use another key to store cache.

I am simply guessing. Am I on the right track? Will this work?

Regards,
Apple Grew
my blog @ http://blog.applegrew.com/

Re: Picking different CSS for different styles.

Posted by Apple Grew <ap...@gmail.com>.
Hey Thanks a lot. I guess header contributor will be the best choice.

Regards,
Apple Grew
my blog @ http://blog.applegrew.com/


On Fri, Apr 9, 2010 at 11:31 PM, Jeremy Thomerson <jeremy@wickettraining.com
> wrote:

> Inline....
>
> On Fri, Apr 9, 2010 at 12:55 PM, Apple Grew <ap...@gmail.com> wrote:
>
> > @Jeremy
> >
> > If generated Htmls are not cached then how does wicket achieve such good
> > performance? I guess the markups are loaded in memory and the wicket
> > components are filled-in at each request. Is it so?
>
>
> Yes - the markup is parsed and cached.  Then for each render, it is
> attached
> to those components and they render the dynamic portions....
>
>
> > So, if I have a <link>
> > tag that points to a static url which is modified at runtime by
> > AutoLinkResolver, will that too be refreshed at every request?
> >
>
> It's been a while since I've used AutoLinkResolver, but this should be the
> case.  Just test and see.  That's the best answer.
>
>
> >
> > @Igor
> >
> > CSS are are provided outside Wicket, i.e. by third party application.
> >
> > So if we have say 2 CSSes - all.css and base.css and, two themes -
> classic
> > and jazzy, then they will be available at static urls like,
> > /classic-all.css
> > /classic-base.css, /jazzy-all.css and /jazzy-base.css.
> >
> > Now if Htmls will have <link> tag in the <head>. The urls of the <link>
> > will
> > be modified at runtime. If generated Htmls are cached then on next access
> > to
> > this page the code to refresh the <link> url can't be refreshed, and it
> > will
> > continue to point at /classic-all.css instead of /jazzy-all.css.
> >
> >
> But generated HTML is not cached.  The best way to accomplish what you're
> doing is not to put the CSS reference in the HTML, because then you have no
> way to modify it.  You should add the CSS reference through a header
> contributor in your java code so that it is added on each request with the
> right reference to your themed file(s).
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>

Re: Picking different CSS for different styles.

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Inline....

On Fri, Apr 9, 2010 at 12:55 PM, Apple Grew <ap...@gmail.com> wrote:

> @Jeremy
>
> If generated Htmls are not cached then how does wicket achieve such good
> performance? I guess the markups are loaded in memory and the wicket
> components are filled-in at each request. Is it so?


Yes - the markup is parsed and cached.  Then for each render, it is attached
to those components and they render the dynamic portions....


> So, if I have a <link>
> tag that points to a static url which is modified at runtime by
> AutoLinkResolver, will that too be refreshed at every request?
>

It's been a while since I've used AutoLinkResolver, but this should be the
case.  Just test and see.  That's the best answer.


>
> @Igor
>
> CSS are are provided outside Wicket, i.e. by third party application.
>
> So if we have say 2 CSSes - all.css and base.css and, two themes - classic
> and jazzy, then they will be available at static urls like,
> /classic-all.css
> /classic-base.css, /jazzy-all.css and /jazzy-base.css.
>
> Now if Htmls will have <link> tag in the <head>. The urls of the <link>
> will
> be modified at runtime. If generated Htmls are cached then on next access
> to
> this page the code to refresh the <link> url can't be refreshed, and it
> will
> continue to point at /classic-all.css instead of /jazzy-all.css.
>
>
But generated HTML is not cached.  The best way to accomplish what you're
doing is not to put the CSS reference in the HTML, because then you have no
way to modify it.  You should add the CSS reference through a header
contributor in your java code so that it is added on each request with the
right reference to your themed file(s).

--
Jeremy Thomerson
http://www.wickettraining.com

Re: Picking different CSS for different styles.

Posted by Apple Grew <ap...@gmail.com>.
@Jeremy

If generated Htmls are not cached then how does wicket achieve such good
performance? I guess the markups are loaded in memory and the wicket
components are filled-in at each request. Is it so? So, if I have a <link>
tag that points to a static url which is modified at runtime by
AutoLinkResolver, will that too be refreshed at every request?

@Igor

CSS are are provided outside Wicket, i.e. by third party application.

So if we have say 2 CSSes - all.css and base.css and, two themes - classic
and jazzy, then they will be available at static urls like, /classic-all.css
/classic-base.css, /jazzy-all.css and /jazzy-base.css.

Now if Htmls will have <link> tag in the <head>. The urls of the <link> will
be modified at runtime. If generated Htmls are cached then on next access to
this page the code to refresh the <link> url can't be refreshed, and it will
continue to point at /classic-all.css instead of /jazzy-all.css.

Regards,
Apple Grew
my blog @ http://blog.applegrew.com/


On Fri, Apr 9, 2010 at 11:08 PM, Jeremy Thomerson <jeremy@wickettraining.com
> wrote:

> Wicket does not cache the *generated HTML, which is I believe what you are
> concerned about.*
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
>
>
> On Fri, Apr 9, 2010 at 12:18 PM, Igor Vaynberg <igor.vaynberg@gmail.com
> >wrote:
>
> > why does it matter if html is cached? you already said its all the same.
> >
> > as far as css resource caching, the theme name is in the url to the
> > css resource as per your example, so once again why does it matter if
> > its cached?
> >
> > -igor
> >
> > On Fri, Apr 9, 2010 at 10:07 AM, Apple Grew <ap...@gmail.com> wrote:
> > > Hi All,
> > >
> > > I am trying to create a themable wicket application which has one html
> > per
> > > page but different CSS files to change its looks. The CSS files are
> > > referenced in the <head> of the html. The CSS files have been named as
> -
> > > <theme_name>-all.css. I am very well able to dynamically generate the
> CSS
> > > urls based on the theme name. The theme names are fetched from session,
> > as,
> > > MySession.getThemeName().
> > >
> > > My concern is, that Wicket might cache the generated html file. So even
> > if
> > > the theme changes at runtime, the html with old CSS names will be
> served.
> > > Furthermore, each user can have different themes, but here we have only
> > > html.
> > >
> > > If my understanding is correct then I should set the style to the theme
> > > name. I read somewhere that Wicket generates keys to reference the
> cached
> > > resources. So, I am guessing, that user A tries to access Home.html
> with
> > > 'classic' style then Wicket will render and cache that page as (say)
> > > classic-Home. Now, if user B tries to access the same page but with
> style
> > > 'jazzy' then Wicket will use another key to store cache.
> > >
> > > I am simply guessing. Am I on the right track? Will this work?
> > >
> > > Regards,
> > > Apple Grew
> > > my blog @ http://blog.applegrew.com/
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>

Re: Picking different CSS for different styles.

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Wicket does not cache the *generated HTML, which is I believe what you are
concerned about.*

--
Jeremy Thomerson
http://www.wickettraining.com



On Fri, Apr 9, 2010 at 12:18 PM, Igor Vaynberg <ig...@gmail.com>wrote:

> why does it matter if html is cached? you already said its all the same.
>
> as far as css resource caching, the theme name is in the url to the
> css resource as per your example, so once again why does it matter if
> its cached?
>
> -igor
>
> On Fri, Apr 9, 2010 at 10:07 AM, Apple Grew <ap...@gmail.com> wrote:
> > Hi All,
> >
> > I am trying to create a themable wicket application which has one html
> per
> > page but different CSS files to change its looks. The CSS files are
> > referenced in the <head> of the html. The CSS files have been named as -
> > <theme_name>-all.css. I am very well able to dynamically generate the CSS
> > urls based on the theme name. The theme names are fetched from session,
> as,
> > MySession.getThemeName().
> >
> > My concern is, that Wicket might cache the generated html file. So even
> if
> > the theme changes at runtime, the html with old CSS names will be served.
> > Furthermore, each user can have different themes, but here we have only
> > html.
> >
> > If my understanding is correct then I should set the style to the theme
> > name. I read somewhere that Wicket generates keys to reference the cached
> > resources. So, I am guessing, that user A tries to access Home.html with
> > 'classic' style then Wicket will render and cache that page as (say)
> > classic-Home. Now, if user B tries to access the same page but with style
> > 'jazzy' then Wicket will use another key to store cache.
> >
> > I am simply guessing. Am I on the right track? Will this work?
> >
> > Regards,
> > Apple Grew
> > my blog @ http://blog.applegrew.com/
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Picking different CSS for different styles.

Posted by Igor Vaynberg <ig...@gmail.com>.
why does it matter if html is cached? you already said its all the same.

as far as css resource caching, the theme name is in the url to the
css resource as per your example, so once again why does it matter if
its cached?

-igor

On Fri, Apr 9, 2010 at 10:07 AM, Apple Grew <ap...@gmail.com> wrote:
> Hi All,
>
> I am trying to create a themable wicket application which has one html per
> page but different CSS files to change its looks. The CSS files are
> referenced in the <head> of the html. The CSS files have been named as -
> <theme_name>-all.css. I am very well able to dynamically generate the CSS
> urls based on the theme name. The theme names are fetched from session, as,
> MySession.getThemeName().
>
> My concern is, that Wicket might cache the generated html file. So even if
> the theme changes at runtime, the html with old CSS names will be served.
> Furthermore, each user can have different themes, but here we have only
> html.
>
> If my understanding is correct then I should set the style to the theme
> name. I read somewhere that Wicket generates keys to reference the cached
> resources. So, I am guessing, that user A tries to access Home.html with
> 'classic' style then Wicket will render and cache that page as (say)
> classic-Home. Now, if user B tries to access the same page but with style
> 'jazzy' then Wicket will use another key to store cache.
>
> I am simply guessing. Am I on the right track? Will this work?
>
> Regards,
> Apple Grew
> my blog @ http://blog.applegrew.com/
>

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