Location: nl.hippo.cocoon.generation.poll.PollGenerator
The PollGenerator returns an xml representation of a single poll. For example:
<?xml version="1.0" encoding="utf-8"?> <poll xmlns="http://hippo.nl/cocoon/generation/poll" all-vote-count="7" pollid="127"> <question>Is the test working 1</question> <headertext>UnitTesting</headertext> <repodocument>/document/test11</repodocument> <isonline>true</isonline> <onlinedate date-format="dd-MM-yyyy">19-03-2007</onlinedate> <answers total="4"> <answer id="225"> <text>Test answer 1</text> <vote-count>4</vote-count> <vote-percentage>57</vote-percentage> </answer> <answer id="226"> <text>Test answer 2</text> <vote-count>3</vote-count> <vote-percentage>43</vote-percentage> </answer> <answer id="227"> <text>Test answer 3</text> <vote-count>0</vote-count> <vote-percentage>0</vote-percentage> </answer> <answer id="228"> <text>Test answer 4</text> <vote-count>0</vote-count> <vote-percentage>0</vote-percentage> </answer> </answers> </poll>
A default xsl stylesheet that transforms this xml into a poll can be found here. The action of the form that does the post returns to the same url. The PollGenerator captures the vote, set a cookie for the user and returns the xml of the poll, now adding an attribute voted="true" to the <poll> element. This indicates how to present the form on the frontend.
The PollGenerator need at least one parameter to function properly:
<map:parameter name="pollid" value="{request-param:pollid}"/>
This id is needed to handle somebody's vote, or to open a different poll then the default (most recently added poll which is active).
An example of the PollGenerator in the sitemap looks like:
<map:generate type="poll"> <map:parameter name="pollid" value="{request-param:pollid}"/> <map:parameter name="dateformat" value="dd-MM-yyyy"/> </map:generate>