我的代码如下所示
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"));
}
答案 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"));
}