简体   繁体   English

将CSS资源添加到Wicket Web App

[英]Adding CSS resource to Wicket Web App

I wanna simply add my css resource to the web page. 我只想将我的CSS资源添加到网页中。 i have one BasePage class which all derived web pages will share the same css styles. 我有一个BasePage类,所有派生的网页将共享相同的CSS样式。 how may i apply css to web pages in the simplest form ? 如何将CSS以最简单的形式应用于网页?

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. Wicket版本是1.5.3。 and im using NetBeans with its plugin. 和即时通讯使用NetBeans及其插件。

Please take into account that im newbie to both Wicket and Web generally. 请考虑到Wicket和Web通常都是新手。 Thanks for answers. 感谢您的回答。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM