2017-08-03 51 views
0

我有代碼如下所示代用HeaderContributor.forCss()的

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

應該繼續使用PackageResourceReferences:

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