0

I wanna simply add my css resource to the web page. i have one BasePage class which all derived web pages will share the same css styles. how may i apply css to web pages in the simplest form ?

These are what i've found and tried to do according to the tutorials* :

public BasePage(IModel model) {
    super(model);
    // won't work due to StyleSheetReference not getting found
    this.add(new StyleSheetReference(BasePage.class, "stylesheet", "style.css"));
    this.add(CSSPackageResource.getHeaderContribution(BasePage.class, "style.css"));

Wicket version is 1.5.3. and im using NetBeans with its plugin.

Please take into account that im newbie to both Wicket and Web generally. Thanks for answers.

NotCamelCase
  • 1,073
  • 1
  • 10
  • 18

1 Answers1

3

Use renderhead:

public class MyPage extends WebPage {
  public MyPage() {
  }
  public void renderHead(IHeaderResponse response) {
    response.renderJavaScriptReference(new PackageResourceReference(YuiLib.class,
      "yahoo-dom-event/yahoo-dom-event.js"));
    response.renderCSSReference(new PackageResourceReference(AbstractCalendar.class,
      "assets/skins/sam/calendar.css"));
  }
}
Stijn Geukens
  • 15,454
  • 8
  • 66
  • 101
  • Thank you but i'd not get the connection point really. how does it now relate the css to the accurate wicket element whose id is "stylesheet" ? in StyleSheetReference(), the 2nd argument is the wicket id whose css will be applied. – NotCamelCase May 13 '12 at 12:28
  • Why do you need that reference? Where will you use that? If you want to include the same CSS resource to all your pages then simply override `renderHead`in your base page and all your child pages will have this CSS. 5do make sure to use `BasePage.class` and not `getClass()` in that case). – Stijn Geukens May 13 '12 at 12:34