Hi,

We've written a (wicket 1.5) class for this: ClassResourcesMapper. It allows you to map all resources under a class (the scope) at a fixed url.

I've put it on pastebin: http://pastebin.com/0vGHCRMs

Met vriendelijke groet,
Kind regards,

Bas Gooren

Op 3-5-2013 9:02, schreef Herman Suijs:
Hi all,

I'm working on multiple portals which use a common-wicket jar containing
HTML, styling and some common components. I'm using Wicket 1.5.

What I'm trying to do is to render the css in the AbstractPage in this jar
module as /css/screen.css.

Because I don't have an Application class in common-wicket, I use an
Initializer to create a SharedResource:
         SharedResources sharedResources = application.getSharedResources();
         sharedResources.add("css/screen.css", new
CssPackageResource(this.getClass(), "css/screen.css", null, null, null));
         sharedResources.add("css/print.css", new
CssPackageResource(this.getClass(), "css/print.css", null, null, null));

screen.css imports other css files from the same directory. As far as I
know I need to have the css/screen.css relative to the Initializer above,
so it can find the screen.css and the css to import. But I'm not sure.

In the AbstractPage I render the CSS like this:
         response.renderCSSReference(new
SharedResourceReference(CommonWicketInitializer.class, "css/screen.css"),
"screen");
         response.renderCSSReference(new
SharedResourceReference(CommonWicketInitializer.class,"css/print.css"),
"print");

This gives me a url in the HTML:
<link rel="stylesheet" type="text/css"
href="../resource/my.package.view.CommonWicketInitializer/css/screen-ver-1367498513000.css"
media="screen" />

I've tried to do mountResource on the screen.css:
         ICompoundRequestMapper rootRequestMapperAsCompound =
application.getRootRequestMapperAsCompound();
         rootRequestMapperAsCompound.add(new
ResourceMapper("css/screen.css", new
PackageResourceReference(this.getClass(), "css/screen.css")));

This makes my screen.css available as /css/screen.css, but the imported css
files cannot be retrieved.

I've been looking for a way to mount /css and all beneath it, but I've
found no way to do that yet.

Maybe someone can help me with this.

Thanks.


Reply via email to