NotCamelCase
NotCamelCase

Reputation: 1083

Adding CSS resource to Wicket Web App

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.

Upvotes: 0

Views: 2800

Answers (1)

Stijn Geukens
Stijn Geukens

Reputation: 15628

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"));
  }
}

Upvotes: 3

Related Questions