在wicket 6.x中替换HeaderContributor.forCss()

时间:2017-08-03 07:30:59

标签: wicket wicket-6 wicket-1.5 wicket-1.6

我的代码如下所示

public class ClasChangePassword extends OhterClass{
private Form frmChangePassword = null;

public ClasChangePassword(final PageParameters parameters) {
// some code.....
........
}

public void ChangePassword() {
frmChangePassword = new Form("cpform") {
protected void onSubmit() {
//some code...
}
};

frmChangePassword.add(pageFeedback);

        frmChangePassword.add(HeaderContributor.forJavaScript(ClasChangePassword.class, "keypass.js"));
        frmChangePassword.add(HeaderContributor.forCss(ClasChangePassword.class, "keypass.css"));

}

我替换了frmChangePassword.add(HeaderContributor.forCss(ClasChangePassword.class,“keypass.css”));使用以下方法的代码,但无法加载css文件

@Override
    public void renderHead(IHeaderResponse response) {
        response.render(JavaScriptHeaderItem.forUrl("keypass.js"));
        response.render(CssHeaderItem.forUrl("keypass.css"));
    }

1 个答案:

答案 0 :(得分:1)

它应该继续使用PackageResourceReferences:

@Override
public void renderHead(IHeaderResponse response) {
    response.render(JavaScriptHeaderItem.forReference(ClasChangePassword.class,  "keypass.js"));
    response.render(CssHeaderItem.forReference(ClasChangePassword.class,  "keypass.css"));
}