You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Arunachalam Sibisakkaravarthi <ar...@mcruncher.com> on 2021/09/08 03:47:22 UTC

Adding css resource available to all component in the application using wicket 9.x

Hi guys,
I am doing Wicket migration from 7.x to 9.x
In Wicket7.x I add css resource as below, it was working

getHeaderResponseDecorators().add(getHeaderResponseDecorator());

private IHeaderResponseDecorator getHeaderResponseDecorator()
{
    return response -> {
        response.render(CssHeaderItem.forReference(css1));

        response.render(CssHeaderItem.forReference(css2));

return new JavaScriptFilteredIntoFooterHeaderResponse(response, "scripts");
};

whereas the above one doesn't work in Wicket9.x
Is there any alternative to css and js in init() method of WebApplication?
so that css/js will be available to all components.



*Thanks And RegardsSibi.ArunachalammCruncher*

Re: Adding css resource available to all component in the application using wicket 9.x

Posted by Arunachalam Sibisakkaravarthi <ar...@mcruncher.com>.
I've found some problems (loading js at page level) in loading js resources
in our web application.
It might be the cause of loading js in the header section, we have to
verify it in our app
I'll create a mini application if needed.
Thanks guys



*Thanks And RegardsSibi.ArunachalammCruncher*


On Thu, Sep 9, 2021 at 1:02 PM Martin Grigorov <mg...@apache.org> wrote:

> Please create a mini application demonstrating the issue and share it at
> GitHub.
>
> On Thu, Sep 9, 2021, 05:56 Arunachalam Sibisakkaravarthi <
> arunachalam@mcruncher.com> wrote:
>
> > Yes somehow It worked in 7.x
> > Based on the suggestions from you all, In 9.x, I use  custom
> > IHeaderResponseDecorator
> > for Css resources to load into the header section, it works.
> > And JavaScriptFilteredIntoFooterHeaderResponse is used with a
> > wicket-container bucket for JS resources to load into the footer before
> end
> > of body, but it loads into header section which is not expected.
> >
> > *Thanks And Regards*
> >
> > *Sibi.ArunachalammCruncher*
> >
> >
> > On Wed, Sep 8, 2021 at 5:14 PM Martin Grigorov <mg...@apache.org>
> > wrote:
> >
> > > On Wed, Sep 8, 2021 at 12:04 PM Arunachalam Sibisakkaravarthi <
> > > arunachalam@mcruncher.com> wrote:
> > >
> > > > Thanks guys for your feedback
> > > > Implementing custom IHeaderResponseDecorator for css resources works
> > for
> > > > me.
> > > > Then I noticed that both css and js resources are loaded in the
> header.
> > > Is
> > > > that expected behaviour in Wicket 9.x? because in my previous
> > > > implementation in Wicket 7.x JS loaded in the footer which is
> expected.
> > > > How do I make the JS to be loaded in the footer to improve page
> loading
> > > > performance?
> > > > @Martin Grigorov somehow adding css resources into
> > > > getHeaderContributorListeners
> > > > doesn't work in my case.
> > > >
> > > >
> > > You should wrap your CssHeaderItems into FilteredHeaderItem if you want
> > > them to be caught by JavaScriptFilteredIntoFooterHeaderResponse.
> > > But I wonder how this worked for you in 7.x.
> > > JavaScriptFilteredIntoFooterHeaderResponse is about
> > JavaScriptHeaderItems,
> > > not CssHeaderItems.
> > >
> > >
> > > >
> > > >
> > > > *Thanks And RegardsSibi.ArunachalammCruncher*
> > > >
> > > >
> > > > On Wed, Sep 8, 2021 at 2:24 PM Martin Grigorov <mgrigorov@apache.org
> >
> > > > wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > Instead of dealing with response decorators you could
> > > > > use org.apache.wicket.markup.html.IHeaderContributor
> > > > >
> > > > > getHeaderContributorListeners().add( return response -> {
> > > > >         response.render(CssHeaderItem.forReference(css1));
> > > > >         response.render(CssHeaderItem.forReference(css2));
> > > > > })
> > > > >
> > > > > IHeaderResponseDecorator is more powerful. It should be used when
> you
> > > > want
> > > > > to intercept all header contributions and add/modify/remove
> > > > contributions.
> > > > >
> > > > > On Wed, Sep 8, 2021 at 6:47 AM Arunachalam Sibisakkaravarthi <
> > > > > arunachalam@mcruncher.com> wrote:
> > > > >
> > > > > > Hi guys,
> > > > > > I am doing Wicket migration from 7.x to 9.x
> > > > > > In Wicket7.x I add css resource as below, it was working
> > > > > >
> > > > > > getHeaderResponseDecorators().add(getHeaderResponseDecorator());
> > > > > >
> > > > > > private IHeaderResponseDecorator getHeaderResponseDecorator()
> > > > > > {
> > > > > >     return response -> {
> > > > > >         response.render(CssHeaderItem.forReference(css1));
> > > > > >
> > > > > >         response.render(CssHeaderItem.forReference(css2));
> > > > > >
> > > > > > return new JavaScriptFilteredIntoFooterHeaderResponse(response,
> > > > > "scripts");
> > > > > > };
> > > > > >
> > > > > > whereas the above one doesn't work in Wicket9.x
> > > > > > Is there any alternative to css and js in init() method of
> > > > > WebApplication?
> > > > > > so that css/js will be available to all components.
> > > > > >
> > > > > >
> > > > > >
> > > > > > *Thanks And RegardsSibi.ArunachalammCruncher*
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: Adding css resource available to all component in the application using wicket 9.x

Posted by Martin Grigorov <mg...@apache.org>.
Please create a mini application demonstrating the issue and share it at
GitHub.

On Thu, Sep 9, 2021, 05:56 Arunachalam Sibisakkaravarthi <
arunachalam@mcruncher.com> wrote:

> Yes somehow It worked in 7.x
> Based on the suggestions from you all, In 9.x, I use  custom
> IHeaderResponseDecorator
> for Css resources to load into the header section, it works.
> And JavaScriptFilteredIntoFooterHeaderResponse is used with a
> wicket-container bucket for JS resources to load into the footer before end
> of body, but it loads into header section which is not expected.
>
> *Thanks And Regards*
>
> *Sibi.ArunachalammCruncher*
>
>
> On Wed, Sep 8, 2021 at 5:14 PM Martin Grigorov <mg...@apache.org>
> wrote:
>
> > On Wed, Sep 8, 2021 at 12:04 PM Arunachalam Sibisakkaravarthi <
> > arunachalam@mcruncher.com> wrote:
> >
> > > Thanks guys for your feedback
> > > Implementing custom IHeaderResponseDecorator for css resources works
> for
> > > me.
> > > Then I noticed that both css and js resources are loaded in the header.
> > Is
> > > that expected behaviour in Wicket 9.x? because in my previous
> > > implementation in Wicket 7.x JS loaded in the footer which is expected.
> > > How do I make the JS to be loaded in the footer to improve page loading
> > > performance?
> > > @Martin Grigorov somehow adding css resources into
> > > getHeaderContributorListeners
> > > doesn't work in my case.
> > >
> > >
> > You should wrap your CssHeaderItems into FilteredHeaderItem if you want
> > them to be caught by JavaScriptFilteredIntoFooterHeaderResponse.
> > But I wonder how this worked for you in 7.x.
> > JavaScriptFilteredIntoFooterHeaderResponse is about
> JavaScriptHeaderItems,
> > not CssHeaderItems.
> >
> >
> > >
> > >
> > > *Thanks And RegardsSibi.ArunachalammCruncher*
> > >
> > >
> > > On Wed, Sep 8, 2021 at 2:24 PM Martin Grigorov <mg...@apache.org>
> > > wrote:
> > >
> > > > Hi,
> > > >
> > > > Instead of dealing with response decorators you could
> > > > use org.apache.wicket.markup.html.IHeaderContributor
> > > >
> > > > getHeaderContributorListeners().add( return response -> {
> > > >         response.render(CssHeaderItem.forReference(css1));
> > > >         response.render(CssHeaderItem.forReference(css2));
> > > > })
> > > >
> > > > IHeaderResponseDecorator is more powerful. It should be used when you
> > > want
> > > > to intercept all header contributions and add/modify/remove
> > > contributions.
> > > >
> > > > On Wed, Sep 8, 2021 at 6:47 AM Arunachalam Sibisakkaravarthi <
> > > > arunachalam@mcruncher.com> wrote:
> > > >
> > > > > Hi guys,
> > > > > I am doing Wicket migration from 7.x to 9.x
> > > > > In Wicket7.x I add css resource as below, it was working
> > > > >
> > > > > getHeaderResponseDecorators().add(getHeaderResponseDecorator());
> > > > >
> > > > > private IHeaderResponseDecorator getHeaderResponseDecorator()
> > > > > {
> > > > >     return response -> {
> > > > >         response.render(CssHeaderItem.forReference(css1));
> > > > >
> > > > >         response.render(CssHeaderItem.forReference(css2));
> > > > >
> > > > > return new JavaScriptFilteredIntoFooterHeaderResponse(response,
> > > > "scripts");
> > > > > };
> > > > >
> > > > > whereas the above one doesn't work in Wicket9.x
> > > > > Is there any alternative to css and js in init() method of
> > > > WebApplication?
> > > > > so that css/js will be available to all components.
> > > > >
> > > > >
> > > > >
> > > > > *Thanks And RegardsSibi.ArunachalammCruncher*
> > > > >
> > > >
> > >
> >
>

Re: Adding css resource available to all component in the application using wicket 9.x

Posted by Arunachalam Sibisakkaravarthi <ar...@mcruncher.com>.
Yes somehow It worked in 7.x
Based on the suggestions from you all, In 9.x, I use  custom
IHeaderResponseDecorator
for Css resources to load into the header section, it works.
And JavaScriptFilteredIntoFooterHeaderResponse is used with a
wicket-container bucket for JS resources to load into the footer before end
of body, but it loads into header section which is not expected.

*Thanks And Regards*

*Sibi.ArunachalammCruncher*


On Wed, Sep 8, 2021 at 5:14 PM Martin Grigorov <mg...@apache.org> wrote:

> On Wed, Sep 8, 2021 at 12:04 PM Arunachalam Sibisakkaravarthi <
> arunachalam@mcruncher.com> wrote:
>
> > Thanks guys for your feedback
> > Implementing custom IHeaderResponseDecorator for css resources works for
> > me.
> > Then I noticed that both css and js resources are loaded in the header.
> Is
> > that expected behaviour in Wicket 9.x? because in my previous
> > implementation in Wicket 7.x JS loaded in the footer which is expected.
> > How do I make the JS to be loaded in the footer to improve page loading
> > performance?
> > @Martin Grigorov somehow adding css resources into
> > getHeaderContributorListeners
> > doesn't work in my case.
> >
> >
> You should wrap your CssHeaderItems into FilteredHeaderItem if you want
> them to be caught by JavaScriptFilteredIntoFooterHeaderResponse.
> But I wonder how this worked for you in 7.x.
> JavaScriptFilteredIntoFooterHeaderResponse is about JavaScriptHeaderItems,
> not CssHeaderItems.
>
>
> >
> >
> > *Thanks And RegardsSibi.ArunachalammCruncher*
> >
> >
> > On Wed, Sep 8, 2021 at 2:24 PM Martin Grigorov <mg...@apache.org>
> > wrote:
> >
> > > Hi,
> > >
> > > Instead of dealing with response decorators you could
> > > use org.apache.wicket.markup.html.IHeaderContributor
> > >
> > > getHeaderContributorListeners().add( return response -> {
> > >         response.render(CssHeaderItem.forReference(css1));
> > >         response.render(CssHeaderItem.forReference(css2));
> > > })
> > >
> > > IHeaderResponseDecorator is more powerful. It should be used when you
> > want
> > > to intercept all header contributions and add/modify/remove
> > contributions.
> > >
> > > On Wed, Sep 8, 2021 at 6:47 AM Arunachalam Sibisakkaravarthi <
> > > arunachalam@mcruncher.com> wrote:
> > >
> > > > Hi guys,
> > > > I am doing Wicket migration from 7.x to 9.x
> > > > In Wicket7.x I add css resource as below, it was working
> > > >
> > > > getHeaderResponseDecorators().add(getHeaderResponseDecorator());
> > > >
> > > > private IHeaderResponseDecorator getHeaderResponseDecorator()
> > > > {
> > > >     return response -> {
> > > >         response.render(CssHeaderItem.forReference(css1));
> > > >
> > > >         response.render(CssHeaderItem.forReference(css2));
> > > >
> > > > return new JavaScriptFilteredIntoFooterHeaderResponse(response,
> > > "scripts");
> > > > };
> > > >
> > > > whereas the above one doesn't work in Wicket9.x
> > > > Is there any alternative to css and js in init() method of
> > > WebApplication?
> > > > so that css/js will be available to all components.
> > > >
> > > >
> > > >
> > > > *Thanks And RegardsSibi.ArunachalammCruncher*
> > > >
> > >
> >
>

Re: Adding css resource available to all component in the application using wicket 9.x

Posted by Martin Grigorov <mg...@apache.org>.
On Wed, Sep 8, 2021 at 12:04 PM Arunachalam Sibisakkaravarthi <
arunachalam@mcruncher.com> wrote:

> Thanks guys for your feedback
> Implementing custom IHeaderResponseDecorator for css resources works for
> me.
> Then I noticed that both css and js resources are loaded in the header. Is
> that expected behaviour in Wicket 9.x? because in my previous
> implementation in Wicket 7.x JS loaded in the footer which is expected.
> How do I make the JS to be loaded in the footer to improve page loading
> performance?
> @Martin Grigorov somehow adding css resources into
> getHeaderContributorListeners
> doesn't work in my case.
>
>
You should wrap your CssHeaderItems into FilteredHeaderItem if you want
them to be caught by JavaScriptFilteredIntoFooterHeaderResponse.
But I wonder how this worked for you in 7.x.
JavaScriptFilteredIntoFooterHeaderResponse is about JavaScriptHeaderItems,
not CssHeaderItems.


>
>
> *Thanks And RegardsSibi.ArunachalammCruncher*
>
>
> On Wed, Sep 8, 2021 at 2:24 PM Martin Grigorov <mg...@apache.org>
> wrote:
>
> > Hi,
> >
> > Instead of dealing with response decorators you could
> > use org.apache.wicket.markup.html.IHeaderContributor
> >
> > getHeaderContributorListeners().add( return response -> {
> >         response.render(CssHeaderItem.forReference(css1));
> >         response.render(CssHeaderItem.forReference(css2));
> > })
> >
> > IHeaderResponseDecorator is more powerful. It should be used when you
> want
> > to intercept all header contributions and add/modify/remove
> contributions.
> >
> > On Wed, Sep 8, 2021 at 6:47 AM Arunachalam Sibisakkaravarthi <
> > arunachalam@mcruncher.com> wrote:
> >
> > > Hi guys,
> > > I am doing Wicket migration from 7.x to 9.x
> > > In Wicket7.x I add css resource as below, it was working
> > >
> > > getHeaderResponseDecorators().add(getHeaderResponseDecorator());
> > >
> > > private IHeaderResponseDecorator getHeaderResponseDecorator()
> > > {
> > >     return response -> {
> > >         response.render(CssHeaderItem.forReference(css1));
> > >
> > >         response.render(CssHeaderItem.forReference(css2));
> > >
> > > return new JavaScriptFilteredIntoFooterHeaderResponse(response,
> > "scripts");
> > > };
> > >
> > > whereas the above one doesn't work in Wicket9.x
> > > Is there any alternative to css and js in init() method of
> > WebApplication?
> > > so that css/js will be available to all components.
> > >
> > >
> > >
> > > *Thanks And RegardsSibi.ArunachalammCruncher*
> > >
> >
>

Re: Adding css resource available to all component in the application using wicket 9.x

Posted by Arunachalam Sibisakkaravarthi <ar...@mcruncher.com>.
Thanks guys for your feedback
Implementing custom IHeaderResponseDecorator for css resources works for me.
Then I noticed that both css and js resources are loaded in the header. Is
that expected behaviour in Wicket 9.x? because in my previous
implementation in Wicket 7.x JS loaded in the footer which is expected.
How do I make the JS to be loaded in the footer to improve page loading
performance?
@Martin Grigorov somehow adding css resources into
getHeaderContributorListeners
doesn't work in my case.



*Thanks And RegardsSibi.ArunachalammCruncher*


On Wed, Sep 8, 2021 at 2:24 PM Martin Grigorov <mg...@apache.org> wrote:

> Hi,
>
> Instead of dealing with response decorators you could
> use org.apache.wicket.markup.html.IHeaderContributor
>
> getHeaderContributorListeners().add( return response -> {
>         response.render(CssHeaderItem.forReference(css1));
>         response.render(CssHeaderItem.forReference(css2));
> })
>
> IHeaderResponseDecorator is more powerful. It should be used when you want
> to intercept all header contributions and add/modify/remove contributions.
>
> On Wed, Sep 8, 2021 at 6:47 AM Arunachalam Sibisakkaravarthi <
> arunachalam@mcruncher.com> wrote:
>
> > Hi guys,
> > I am doing Wicket migration from 7.x to 9.x
> > In Wicket7.x I add css resource as below, it was working
> >
> > getHeaderResponseDecorators().add(getHeaderResponseDecorator());
> >
> > private IHeaderResponseDecorator getHeaderResponseDecorator()
> > {
> >     return response -> {
> >         response.render(CssHeaderItem.forReference(css1));
> >
> >         response.render(CssHeaderItem.forReference(css2));
> >
> > return new JavaScriptFilteredIntoFooterHeaderResponse(response,
> "scripts");
> > };
> >
> > whereas the above one doesn't work in Wicket9.x
> > Is there any alternative to css and js in init() method of
> WebApplication?
> > so that css/js will be available to all components.
> >
> >
> >
> > *Thanks And RegardsSibi.ArunachalammCruncher*
> >
>

Re: Adding css resource available to all component in the application using wicket 9.x

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

Instead of dealing with response decorators you could
use org.apache.wicket.markup.html.IHeaderContributor

getHeaderContributorListeners().add( return response -> {
        response.render(CssHeaderItem.forReference(css1));
        response.render(CssHeaderItem.forReference(css2));
})

IHeaderResponseDecorator is more powerful. It should be used when you want
to intercept all header contributions and add/modify/remove contributions.

On Wed, Sep 8, 2021 at 6:47 AM Arunachalam Sibisakkaravarthi <
arunachalam@mcruncher.com> wrote:

> Hi guys,
> I am doing Wicket migration from 7.x to 9.x
> In Wicket7.x I add css resource as below, it was working
>
> getHeaderResponseDecorators().add(getHeaderResponseDecorator());
>
> private IHeaderResponseDecorator getHeaderResponseDecorator()
> {
>     return response -> {
>         response.render(CssHeaderItem.forReference(css1));
>
>         response.render(CssHeaderItem.forReference(css2));
>
> return new JavaScriptFilteredIntoFooterHeaderResponse(response, "scripts");
> };
>
> whereas the above one doesn't work in Wicket9.x
> Is there any alternative to css and js in init() method of WebApplication?
> so that css/js will be available to all components.
>
>
>
> *Thanks And RegardsSibi.ArunachalammCruncher*
>

Re: Adding css resource available to all component in the application using wicket 9.x

Posted by Francois Meillet <fr...@gmail.com>.
Hi Arunachalam,

Migration From Wicket 7 to 8
setHeaderResponseDecorator(new JavaScriptToBodyCustomResponseDecorator("footer"));

Wicket 8
setHeaderResponseDecorator(response -> {
	return new ResourceAggregator(new JavaScriptFilteredIntoFooterHeaderResponse(response, "footer"));
});

Wicket 9
getHeaderResponseDecorators().add(response -> new CustomResponse(response));

For more details, please see
https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=84804436#MigrationtoWicket8.0-WICKET-6498
and
https://cwiki.apache.org/confluence/display/WICKET/Migration+to+Wicket+9.0#MigrationtoWicket9.0-DeprecateAppliation#setHeaderResponseDecorator()ASFJIRAkey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution5aa69414-a9e9-3523-82ec-879b028fb15bWICKET-6729

François


> Le 8 sept. 2021 à 05:47, Arunachalam Sibisakkaravarthi <ar...@mcruncher.com> a écrit :
> 
> Hi guys,
> I am doing Wicket migration from 7.x to 9.x
> In Wicket7.x I add css resource as below, it was working
> 
> getHeaderResponseDecorators().add(getHeaderResponseDecorator());
> 
> private IHeaderResponseDecorator getHeaderResponseDecorator()
> {
>    return response -> {
>        response.render(CssHeaderItem.forReference(css1));
> 
>        response.render(CssHeaderItem.forReference(css2));
> 
> return new JavaScriptFilteredIntoFooterHeaderResponse(response, "scripts");
> };
> 
> whereas the above one doesn't work in Wicket9.x
> Is there any alternative to css and js in init() method of WebApplication?
> so that css/js will be available to all components.
> 
> 
> 
> *Thanks And RegardsSibi.ArunachalammCruncher*


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