I've created a compound document type called SampleCaps in a HippoCMS 7.9 site and set out to build a template for it. In the process, I added hst:sitemap
nodes, a pair of nested hst:pages
nodes, and an hst:templates
node. I also added the appropriate type
property to hippo:namespaces/barcom/SampleCaps
.
Finally, I created a Component and a Bean to expose the document data to the template, adapting the steps presented in part 2 of the Hippo Video Trails.
To my frustration, while the Component loads properly the Bean is never loaded (or at least, its getter is never called.) My component and bean are as follows:
site/src/main/java/com/footech/barcom/components/SampleCapsComponent.java:
package com.footech.barcom.components;
import com.footech.barcom.beans.SampleCapsDocument;
import org.hippoecm.hst.content.beans.standard.HippoBean;
import org.hippoecm.hst.component.support.bean.BaseHstComponent;
import org.hippoecm.hst.core.component.HstComponentException;
import org.hippoecm.hst.core.component.HstRequest;
import org.hippoecm.hst.core.component.HstResponse;
public class SampleCapsComponent extends BaseHstComponent {
@Override
public void doBeforeRender(final HstRequest request, final HstResponse response) throws HstComponentException {
SampleCapsDocument document = request.getRequestContext().getContentBean();
request.setAttribute("document", document);
System.out.println("Ping"); /* prints "Ping" to console */
}
}
site/src/main/java/com/footech/barcom/beans/SampleCapsDocument.java:
package com.footech.barcom.beans;
import java.util.Calendar;
import org.hippoecm.hst.content.beans.Node;
import org.hippoecm.hst.content.beans.standard.HippoHtml;
import org.onehippo.cms7.essentials.dashboard.annotations.HippoEssentialsGenerated;
@HippoEssentialsGenerated(internalName = "barcom:SampleCapsdocument")
@Node(jcrType = "barcom:SampleCapsdocument")
public class SampleCapsDocument extends BaseDocument {
@HippoEssentialsGenerated(internalName = "barcom:title")
public String getTitle() {
System.out.println("Pong"); /* This never triggers */
return getProperty("barcom:title");
}
}
To my understanding, the annotation @Node(jcrType = "barcom:SampleCapsdocument")
in SampleCapsComponent.java should hint to the compiler that the content node should be wrapped with the SampleCapsDocument bean - this does not appear to be the case, as the debug console prints Ping
but not Pong
. What am I doing wrong?