You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Lorne Malvo <ca...@gmail.com> on 2014/07/26 00:51:23 UTC

Problem adding CSS resources in Wicket 6

I have a problem adding CSS resources to Wicket pages in Wicket 6.

In my page class, I override renderHead() like this:

@Override
  public void renderHead(IHeaderResponse response) {
    response.render( CssHeaderItem.forReference( new CssResourceReference(
        MyFantasticPage.class, "MyFantasticPage.css" ) ) );
  }

However, in the resulting HTML code, the link to the CSS file is rendered by
Wicket like this:

<link rel="stylesheet" type="text/css"
href="./wicket/resource/com.myDomain.pages.MyFantasticPage/MyFantasticPage-ver-1406325551266.css"
/>

The link is correct except for this portion: "-ver-1406325551266"

How can I prevent Wicket from adding this extra noise? This is happening in
my entire application for every single page. I've tried a few variations on
my renderHead() implementation, but no luck.

Thank you very much!

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Problem-adding-CSS-resources-in-Wicket-6-tp4666749.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: Problem adding CSS resources in Wicket 6

Posted by Sven Meier <sv...@meiers.net>.
Hi,

the Wicket 6 link looks pretty normal.

Are you using Maven? Did you use Maven previously? Did you add 
'src/main/java' as a resource folder?

Regards
Sven


On 07/27/2014 08:37 PM, Lorne Malvo wrote:
> Thank you, Sven, very helpful!
> However, unfortunately, the read and your suggestion didn't solve my
> problem.
> I'm upgrading a site from Wicket 4 to Wicket 6, and I thought that the
> version numbers in the links to the CSS resources where the reason for
> browsers not finding my CSS resources.
> But it seems that was not the problem after all - the problem seems to be
> that the URLs in the links to my CSS resources in the HTML headers are
> pointing to different locations that they were before.
> For example:
>
> In Wicket 4, the link to a css stylesheet was rendered like this:
>
> <link rel="stylesheet" type="text/css"
> href="resources/com.myFantasticDomain.web.pages.home.HomePage/HomePage.css"
> />
>
> In Wicket 6, the link to the same resource (haven't changed anything about
> the actual resource), the same link is rendered like this.
>
> <link rel="stylesheet" type="text/css"
> href="./wicket/resource/com.myFantasticDomain.web.pages.home.HomePage/HomePage.css"
> />
>
> In Wicket 4, the stylesheet is found by browsers. In Wicket 6, it's not.
>
> Would you know what the problem is here?
>
> Thank you so much! It helps a lot.
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Problem-adding-CSS-resources-in-Wicket-6-tp4666749p4666759.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
>


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


Re: Problem adding CSS resources in Wicket 6

Posted by Lorne Malvo <ca...@gmail.com>.
Thank you, Sven, very helpful!
However, unfortunately, the read and your suggestion didn't solve my
problem.
I'm upgrading a site from Wicket 4 to Wicket 6, and I thought that the
version numbers in the links to the CSS resources where the reason for
browsers not finding my CSS resources.
But it seems that was not the problem after all - the problem seems to be
that the URLs in the links to my CSS resources in the HTML headers are
pointing to different locations that they were before.
For example:

In Wicket 4, the link to a css stylesheet was rendered like this:

<link rel="stylesheet" type="text/css"
href="resources/com.myFantasticDomain.web.pages.home.HomePage/HomePage.css"
/>

In Wicket 6, the link to the same resource (haven't changed anything about
the actual resource), the same link is rendered like this.

<link rel="stylesheet" type="text/css"
href="./wicket/resource/com.myFantasticDomain.web.pages.home.HomePage/HomePage.css"
/>

In Wicket 4, the stylesheet is found by browsers. In Wicket 6, it's not.

Would you know what the problem is here?

Thank you so much! It helps a lot.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Problem-adding-CSS-resources-in-Wicket-6-tp4666749p4666759.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: Problem adding CSS resources in Wicket 6

Posted by Sven Meier <sv...@meiers.net>.
Hi,

you should read 
http://wicket.apache.org/guide/guide/resources.html#resources_3 to 
understand the 'extra noise'.

If you really don't want a version identifier appended, you can use 
NoOpResourceCachingStrategy. See IResourceSettings#setCachingStrategy().

Regards
Sven


On 07/26/2014 12:51 AM, Lorne Malvo wrote:
> I have a problem adding CSS resources to Wicket pages in Wicket 6.
>
> In my page class, I override renderHead() like this:
>
> @Override
>    public void renderHead(IHeaderResponse response) {
>      response.render( CssHeaderItem.forReference( new CssResourceReference(
>          MyFantasticPage.class, "MyFantasticPage.css" ) ) );
>    }
>
> However, in the resulting HTML code, the link to the CSS file is rendered by
> Wicket like this:
>
> <link rel="stylesheet" type="text/css"
> href="./wicket/resource/com.myDomain.pages.MyFantasticPage/MyFantasticPage-ver-1406325551266.css"
> />
>
> The link is correct except for this portion: "-ver-1406325551266"
>
> How can I prevent Wicket from adding this extra noise? This is happening in
> my entire application for every single page. I've tried a few variations on
> my renderHead() implementation, but no luck.
>
> Thank you very much!
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Problem-adding-CSS-resources-in-Wicket-6-tp4666749.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
>


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