javajsphippocms

How to check if empty and display rich text field (HTML) in Hippo CMS template


I have a project built using the Hippo CMS Java framework. I have created a new document type which contains a rich text field. In the document type bean I have a property of type HippoHtml:

@HippoEssentialsGenerated(internalName = "acm:abstract")
public HippoHtml getAbstract() {
    return getHippoHtml("acm:abstract");
}

Other fields of String type work fine:

@HippoEssentialsGenerated(internalName = "acm:title")
public String getTitle() {
    return getProperty("acm:title");
}

In the JSP template I can check and display simple properties like this:

<c:if test="${ not empty result.title  }">
  <h1>${ result.title }</h1>
</c:if>

However, for the HippoHtml property, I cannot get the template to recognize the field. I have tried the following:

<%--@elvariable id="result" type="org.acm.beans.CustomDocument"--%>

<c:if test="${ not empty result.abstract}">
  ${ result.abstract}
</c:if>
...
<c:if test="${ not empty result.abstract  }">
  <hst:html hippohtml="${ result.abstract }"/>
</c:if>
...
<c:if test="${ not empty result.html.abstract  }">
  <hst:html hippohtml="${ result.html.abstract }"/>
</c:if>
...
<c:if test="${ not empty result.html.content}">
  <hst:html hippohtml="${ result.html.content}"/>
</c:if>

I would like to investigate the HippoHtml type. Where in the project files (or online) can I find a class definition for org.hippoecm.hst.content.beans.standard.HippoHtml in order to see the object properties and methods?

How do I check if the document property acm:abstract has a value, then display it in my template?


Solution

  • Check the code: https://code.onehippo.org/

    Or the api: http://javadoc.onehippo.org/11.1/hippo-site-toolkit/

    Or a more general overview page which includes the above links: https://www.onehippo.org/library/about/developer-info.html

    To see if it is empty you can call

    <hst:html hippohtml="${ result.abstract}" var="foo"/>
    

    And then test if foo exists.