I have a CloakDecorator class that implements IAjaxCallDecorator and IHeaderContributor :
public class CloakDecorator implements IAjaxCallDecorator, IHeaderContributor { @SuppressWarnings("unused") private static final ResourceReference INDICATOR = new ResourceReference(CloakDecorator.class, "indicator.gif"); private static final ResourceReference JS = new JavascriptResourceReference(CloakDecorator.class, "CloakDecorator.js"); private static final ResourceReference CSS = new ResourceReference(CloakDecorator.class, "CloakDecorator.css"); public CloakDecorator() { System.out.println("Constructor"); } public void renderHead(final IHeaderResponse response) { System.out.println("renderHead"); response.renderCSSReference(CSS); response.renderJavascriptReference(JS); } @Override public CharSequence decorateScript(CharSequence script) { return script; } @Override public CharSequence decorateOnSuccessScript(CharSequence script) { return script; } @Override public CharSequence decorateOnFailureScript(CharSequence script) { return script; } }
Now from AjaxLink I create an instance of CloakDecorator :
AjaxLink link=new AjaxLink("") { @Override public void onClick(AjaxRequestTarget target) { } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { return new CloakDecorator(); } };
The problem is that the CloakDecorator constructor is being CloakDecorator , but the renderHead method renderHead not being called. What am I doing wrong? I put some System.out.println in the constructor and in the renderHead method, the System.out.println constructor works, but the second doesn't.
source share