Poll Component Developer Guide - Rendering
Rendering the Poll
Available Poll Data
To implement a rendering template (JSP or Freemarker) for the poll component, you need to understand the data available for rendering. The following table lists the fields exposed to your template:
| Field | Description |
|---|---|
| pollDocument | The root-level HST bean representing the processed poll document. For plugin-supplied poll documents, this bean is implemented by org.onehippo.forge.poll.contentbean.PollDocument. If no poll document is present, this field is null. In that case, do not render the poll. Custom poll documents may include additional properties, but the plugin-supplied type exposes only the poll field: |
| pollDocument.poll | The HST bean representing the poll compound, implemented by org.onehippo.forge.poll.contentbean.compound.Poll. |
| pollDocument.poll.text | A string containing the value of the text attribute of the poll compound. |
| pollDocument.poll.introduction | A string containing the value of the introduction attribute of the poll compound. |
| pollDocument.poll.options | A list of HST beans representing the available options for this poll. Each option is implemented by org.onehippo.forge.poll.contentbean.compound.Option. |
| pollDocument.poll.options[].value | A string containing the value attribute of the option. |
| pollDocument.poll.options[].label | A string containing the label attribute of the option. |
| voteSuccess | A boolean indicating whether a voting attempt was successful. This field is only available if a voting attempt was made. |
| option | A string containing the option that was previously voted on. This field may not always be present. |
| pollVotes | A Java bean of type org.onehippo.forge.poll.bean.PollVotesBean containing vote data for the pollDocument. This bean exposes votes data as options: |
| pollVotes.options | A list of beans representing the poll options. |
| pollVotes.options[].value | Same as pollDocument.poll.options[].value. |
| pollVotes.options[].label | Same as pollDocument.poll.options[].label. |
| pollVotes.options[].votesCount | A long integer indicating the number of votes for this option. |
| pollVotes.options[].votesPercentage | A long integer representing the rounded percentage of votes for this option relative to the total votes for the document. |
Creating a Template
Render the poll component using a JSP or Freemarker template. The poll plugin provides a sample Freemarker template that demonstrates how to render the poll attributes. You can find this template in the repository at:
hst:[your_project]/hst:configurations/hst:default/hst:templates/poll.component.ftl@hst:script
To customize the rendering, modify this template as needed and ensure it is included in your site.war deployment.
If you create a custom template, register it under /hst:[your_project]/hst:configurations/[your_project]/hst:templates and set the component's hst:renderpath property to reference your template.

If you use the default Freemarker template provided by the poll plugin, the template poll.component.ftl is available for your component.