Hi,
On Fri, May 3, 2013 at 9:02 AM, Herman Suijs <[email protected]> wrote: > 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 mount will serve only requests to /css/screen.css, but nothing else. You can use something like http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/. In the example is shown how to serve images, but it is the same for any other data type. > > 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. > > -- > Herman Suijs > > http://about.me/hsuijs > http://twitter.com/hsuijs > http://www.linkedin.com/in/hermansuijs > -- Martin Grigorov Wicket Training & Consulting http://jWeekend.com <http://jweekend.com/>
