开发者

Adding css resource available to all component in the application using wicket 1.5

开发者 https://www.devze.com 2023-03-17 05:23 出处:网络
I am using wicket 1.5.x and trying to load a css file which will be shared by all the pages,panels,forms. Right now when I statically adda css file (located in [app]/WebApps/style) directory in my Bas

I am using wicket 1.5.x and trying to load a css file which will be shared by all the pages,panels,forms. Right now when I statically add a css file (located in [app]/WebApps/style) directory in my BasePage and extend other pages.

Now if I want to use this css file for a panel,it does not get any class/id selector when I add a css class into that file for a panel .Neither the CSS file is attached to html head of BasePage. So Instead I wanted to use a global css开发者_JS百科 file. I have tried to do like this:

In my Application class I did like this by calling the following function in init(),

 private void mountResources(){
    mountResource("/css/layout.css", Resources.CSS_BASE);
}

where my Resource class is,

public abstract class Resources {

public static final ResourceReference CSS_BASE 
 = new  CssResourceReference(OrbitApplication.class, "resources/layout.css"); 

}

Here my css is in main/resource/ directory(maven structure). But the css is not loading. I have heared about HeaderContributor but did not find how to use in my wicket 1.5 appllication.

Any idea/snippet of how to do this? help appreciated.


Use

MyApp.init() {
  super.init();

  org.apache.wicket.Application.getHeaderContributorListenerCollection().add(new IHeaderContributor() {

    public void renderHead(IHeaderResponse response) {
      response.renderCssReference(Resources.CSS_BASE);
    }
  });
}

Why don't you read the responses to your questions in IRC ?

0

精彩评论

暂无评论...
验证码 换一张
取 消