You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by fieona <mu...@gmail.com> on 2014/02/26 10:43:55 UTC

Dynamic ResourceBundle (Concat/merge css headerItem on the fly)

Hi,

In our application we have this CssHeaderContributionBehavior which adds a
css sheet for the component it is bound to. (if it exists -of course-)

Something like this:
@Override
    public void renderHead(Component component, IHeaderResponse response) {
		...
		CssResourceReference reference = new
CssResourceReference(component.getClass(),
component.getClass().getSimpleName(), component.getLocale(),
component.getStyle(), component.getVariation());
		...
		response.render(CssHeaderItem.forReference(reference));
}

This behavior is added to our BasePanel. (so each panel can have its own css
sheet). The problem with this approach is that we quicky get a lot of css
sheets. 
Since Internet explorer 9 only supports up to 31 stylesheets 
	 http://support.microsoft.com/kb/262161/en-us
<http://support.microsoft.com/kb/262161/en-us>  
	 https://issues.apache.org/jira/browse/WICKET-4254
<https://issues.apache.org/jira/browse/WICKET-4254>  
AND it would also be faster to just use 1 merged css sheet, I took a look
at: getResourceBundles().add(css)Bundle(..)

The problem I'm having with this, is that you need to this in the
Application init() method. (right?)

Is there a possibility to add the cssResourceReferences on the fly (in our
CssHeaderContributionBehavior?) and then reloading the merged css?

Thanks in advance!

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Dynamic-ResourceBundle-Concat-merge-css-headerItem-on-the-fly-tp4664678.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Dynamic ResourceBundle (Concat/merge css headerItem on the fly)

Posted by Martin Grigorov <mg...@apache.org>.
Yes.
This is similar to how Wicket 1.4 dealt with these matters.

Martin Grigorov
Wicket Training and Consulting


On Wed, Feb 26, 2014 at 12:03 PM, Ernesto Reinaldo Barreiro <
reiern70@gmail.com> wrote:

> Maybe mount a resource to which you pass a "list" of CSS... This resource
> will concatenate them to be served. There could be a "thread local"
> collecting all CSS resources on a request and generating  a unique link
> (with this list of CSS)
>
>
> On Wed, Feb 26, 2014 at 10:55 AM, Martin Grigorov <mgrigorov@apache.org
> >wrote:
>
> > Hi,
> >
> >
> > On Wed, Feb 26, 2014 at 11:43 AM, fieona <mu...@gmail.com> wrote:
> >
> > > Hi,
> > >
> > > In our application we have this CssHeaderContributionBehavior which
> adds
> > a
> > > css sheet for the component it is bound to. (if it exists -of course-)
> > >
> > > Something like this:
> > > @Override
> > >     public void renderHead(Component component, IHeaderResponse
> > response) {
> > >                 ...
> > >                 CssResourceReference reference = new
> > > CssResourceReference(component.getClass(),
> > > component.getClass().getSimpleName(), component.getLocale(),
> > > component.getStyle(), component.getVariation());
> > >                 ...
> > >                 response.render(CssHeaderItem.forReference(reference));
> > > }
> > >
> > > This behavior is added to our BasePanel. (so each panel can have its
> own
> > > css
> > > sheet). The problem with this approach is that we quicky get a lot of
> css
> > > sheets.
> > > Since Internet explorer 9 only supports up to 31 stylesheets
> > >          http://support.microsoft.com/kb/262161/en-us
> > > <http://support.microsoft.com/kb/262161/en-us>
> > >          https://issues.apache.org/jira/browse/WICKET-4254
> > > <https://issues.apache.org/jira/browse/WICKET-4254>
> > > AND it would also be faster to just use 1 merged css sheet, I took a
> look
> > > at: getResourceBundles().add(css)Bundle(..)
> > >
> > > The problem I'm having with this, is that you need to this in the
> > > Application init() method. (right?)
> > >
> >
> > Right.
> > You can do it in any other place too but the behavior will be the same.
> > Just make sure that you register the bundle just once.
> >
> >
> > >
> > > Is there a possibility to add the cssResourceReferences on the fly (in
> > our
> > > CssHeaderContributionBehavior?) and then reloading the merged css?
> > >
> >
> > I think this should be possible by using custom IHeaderResponse that will
> > collect all CssReferenceHeaderItems in a request, merge them and render
> > just one <link> element.
> > It won't be very optimal performance wise but will be very flexible. I
> will
> > play with this idea.
> >
> >
> > >
> > > Thanks in advance!
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://apache-wicket.1842946.n4.nabble.com/Dynamic-ResourceBundle-Concat-merge-css-headerItem-on-the-fly-tp4664678.html
> > > Sent from the Users forum mailing list archive at Nabble.com.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
>
>
>
> --
> Regards - Ernesto Reinaldo Barreiro
>

Re: Dynamic ResourceBundle (Concat/merge css headerItem on the fly)

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Maybe mount a resource to which you pass a "list" of CSS... This resource
will concatenate them to be served. There could be a "thread local"
collecting all CSS resources on a request and generating  a unique link
(with this list of CSS)


On Wed, Feb 26, 2014 at 10:55 AM, Martin Grigorov <mg...@apache.org>wrote:

> Hi,
>
>
> On Wed, Feb 26, 2014 at 11:43 AM, fieona <mu...@gmail.com> wrote:
>
> > Hi,
> >
> > In our application we have this CssHeaderContributionBehavior which adds
> a
> > css sheet for the component it is bound to. (if it exists -of course-)
> >
> > Something like this:
> > @Override
> >     public void renderHead(Component component, IHeaderResponse
> response) {
> >                 ...
> >                 CssResourceReference reference = new
> > CssResourceReference(component.getClass(),
> > component.getClass().getSimpleName(), component.getLocale(),
> > component.getStyle(), component.getVariation());
> >                 ...
> >                 response.render(CssHeaderItem.forReference(reference));
> > }
> >
> > This behavior is added to our BasePanel. (so each panel can have its own
> > css
> > sheet). The problem with this approach is that we quicky get a lot of css
> > sheets.
> > Since Internet explorer 9 only supports up to 31 stylesheets
> >          http://support.microsoft.com/kb/262161/en-us
> > <http://support.microsoft.com/kb/262161/en-us>  
> >          https://issues.apache.org/jira/browse/WICKET-4254
> > <https://issues.apache.org/jira/browse/WICKET-4254>
> > AND it would also be faster to just use 1 merged css sheet, I took a look
> > at: getResourceBundles().add(css)Bundle(..)
> >
> > The problem I'm having with this, is that you need to this in the
> > Application init() method. (right?)
> >
>
> Right.
> You can do it in any other place too but the behavior will be the same.
> Just make sure that you register the bundle just once.
>
>
> >
> > Is there a possibility to add the cssResourceReferences on the fly (in
> our
> > CssHeaderContributionBehavior?) and then reloading the merged css?
> >
>
> I think this should be possible by using custom IHeaderResponse that will
> collect all CssReferenceHeaderItems in a request, merge them and render
> just one <link> element.
> It won't be very optimal performance wise but will be very flexible. I will
> play with this idea.
>
>
> >
> > Thanks in advance!
> >
> > --
> > View this message in context:
> >
> http://apache-wicket.1842946.n4.nabble.com/Dynamic-ResourceBundle-Concat-merge-css-headerItem-on-the-fly-tp4664678.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>



-- 
Regards - Ernesto Reinaldo Barreiro

Re: Dynamic ResourceBundle (Concat/merge css headerItem on the fly)

Posted by Martin Grigorov <mg...@apache.org>.
Hi,


On Wed, Feb 26, 2014 at 11:43 AM, fieona <mu...@gmail.com> wrote:

> Hi,
>
> In our application we have this CssHeaderContributionBehavior which adds a
> css sheet for the component it is bound to. (if it exists -of course-)
>
> Something like this:
> @Override
>     public void renderHead(Component component, IHeaderResponse response) {
>                 ...
>                 CssResourceReference reference = new
> CssResourceReference(component.getClass(),
> component.getClass().getSimpleName(), component.getLocale(),
> component.getStyle(), component.getVariation());
>                 ...
>                 response.render(CssHeaderItem.forReference(reference));
> }
>
> This behavior is added to our BasePanel. (so each panel can have its own
> css
> sheet). The problem with this approach is that we quicky get a lot of css
> sheets.
> Since Internet explorer 9 only supports up to 31 stylesheets
>          http://support.microsoft.com/kb/262161/en-us
> <http://support.microsoft.com/kb/262161/en-us>  
>          https://issues.apache.org/jira/browse/WICKET-4254
> <https://issues.apache.org/jira/browse/WICKET-4254>
> AND it would also be faster to just use 1 merged css sheet, I took a look
> at: getResourceBundles().add(css)Bundle(..)
>
> The problem I'm having with this, is that you need to this in the
> Application init() method. (right?)
>

Right.
You can do it in any other place too but the behavior will be the same.
Just make sure that you register the bundle just once.


>
> Is there a possibility to add the cssResourceReferences on the fly (in our
> CssHeaderContributionBehavior?) and then reloading the merged css?
>

I think this should be possible by using custom IHeaderResponse that will
collect all CssReferenceHeaderItems in a request, merge them and render
just one <link> element.
It won't be very optimal performance wise but will be very flexible. I will
play with this idea.


>
> Thanks in advance!
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Dynamic-ResourceBundle-Concat-merge-css-headerItem-on-the-fly-tp4664678.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>