Woody sample using actions (map:act)

Below we show how the sample from WoodySample can be done using actions. The sourcecode of these actions is included with the Cocoon source code: MakeFormAction and HandleFormSubmitAction.

<map:match pattern="registration">
  <map:select type="request-method">
    <map:when test="GET">
      <map:act type="woody-make-form">
        <map:parameter name="form-definition" value="forms/registration.xml"/>
        <map:parameter name="attribute-name" value="registrationform"/>
      </map:act>
    </map:when>
    <map:otherwise>
      <map:act type="woody-handle-form-submit">
        <map:parameter name="form-definition" value="forms/registration.xml"/>
        <map:parameter name="attribute-name" value="registrationform"/>

        <map:generate type="serverpages" src="forms/registration_success.xsp"/>
        <map:serialize/>
      </map:act>
    </map:otherwise>
  </map:select>

  <map:generate src="forms/registration_template.xml"/>
  <map:transform type="woody">
    <map:parameter name="attribute-name" value="registrationform"/>
  </map:transform>
  <map:transform type="i18n">
    <map:parameter name="locale" value="en-US"/>
  </map:transform>
  <map:transform src="resources/woody-samples-styling.xsl"/>
  <map:transform type="i18n">
    <map:parameter name="locale" value="en-US"/>
  </map:transform>
  <map:serialize/>
</map:match>

How this sitemap works

registration_success.xsp

Here's an example of what the XSP could look like.

<?xml version="1.0"?>
<xsp:page language="java"
  xmlns:xsp="http://apache.org/xsp">

  <xsp:structure>
    <xsp:include>org.apache.cocoon.woody.formmodel.*</xsp:include>
  </xsp:structure>

  <page>
    <title>Registration result</title>
    <content>
      <xsp:logic>
        // get reference to form and some of the widgets on it
        Form form = (Form)request.getAttribute("registrationform");
        Field name = (Field)form.getWidget("name");
      </xsp:logic>

      Registration was successful for <xsp:expr>name.getValue()</xsp:expr>
    </content>
  </page>
</xsp:page>

WoodyActionSample (last edited 2009-09-20 23:39:51 by localhost)