cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [DAISY] Updated: A Simple CForm Example
Date Fri, 21 Nov 2008 18:12:07 GMT
A document has been updated:

Document ID: 478
Branch: main
Language: default
Name: A Simple CForm Example (previously A Simple Example)
Document Type: Cocoon Document (unchanged)
Updated on: 10/15/08 4:09:08 PM
Updated by: David Legg

A new version has been created, state: publish


This part has been updated.
Mime type: text/xml (unchanged)
File name:  (unchanged)
Size: 16511 bytes (previous version: 15359 bytes)
Content diff:
(3 equal lines skipped)
    <h1>A simple CForms example</h1>
    <p>In this example we will show how to create a simple registration form using
--- CForms and flowscript. We will follow to following steps:</p>
+++ CForms and flowscript.  We will follow the following steps:</p>
    <li>Create a block for this sample</li>
(9 equal lines skipped)
    <h1>Create a block</h1>
--- <p>This has been covered in the tutorial, but it won't hurt to recall this Maven
--- goal:</p>
+++ <p>This is covered in the tutorial "<a href="daisy:1159">Your first Cocoon
+++ application using Maven 2</a>", but it won't hurt to repeat it here:</p>
--- <pre>mvn org.apache.maven.plugins:maven-archetype-plugin:1.0-alpha-7:create 
--- -DarchetypeGroupId=org.apache.cocoon 
--- -DarchetypeArtifactId=cocoon-22-archetype-block 
--- -DarchetypeVersion=1.0.0-RC2 -DgroupId=com.mycompany 
--- -DartifactId=simple-sample</pre>
+++ <p>Choose a suitable parent directory in which to create the following example
+++ directory and then run this Maven command:</p>
--- <p class="note">As of the writing of this page, the Maven archetype plugin
--- version has to be specified, due to a bug in the current release of it.</p>
+++ <pre>mvn archetype:generate -DarchetypeCatalog=
+++ </pre>
--- <p>Edit the <tt>simple-sample/pom.xml</tt> file and add the support
for Cocoon
--- Forms:</p>
+++ <p>Maven will generate some output and then interactively ask you for some
+++ information.  You should select item 2 (the cocoon-22-archetype-block):</p>
+++ <pre>Choose archetype:
+++ 1: remote -&gt; cocoon-22-archetype-block-plain (Creates an empty Cocoon block; useful
+++  if you want to add another block to a Cocoon application)
+++ 2: remote -&gt; cocoon-22-archetype-block (Creates a Cocoon block containing some
+++  samples)
+++ 3: remote -&gt; cocoon-22-archetype-webapp (Creates a web application configured to
+++  host Cocoon blocks. Just add the block dependencies)
+++ Choose a number:  (1/2/3): <strong><strong>2</strong></strong>
+++ </pre>
+++ <p>When Maven asks for more details of the block to be created answer as
+++ follows:</p>
+++ <pre><strong> Define value for groupId: : <strong>com.mycompany</strong>
+++ Define value for artifactId: : cformexample
+++ Define value for version:  1.0-SNAPSHOT: : <strong>1.0.0</strong>
+++ Define value for package: : <strong>com.mycompany.cformexample</strong>
+++ </strong> </pre>
+++ <p>A new directory should appear called 'cformexample'.</p>
+++ <p>Change into this directory and edit the <tt>pom.xml</tt> file by
adding a
+++ dependency on Cocoon Forms:</p>
---       &lt;groupId&gt;org.apache.cocoon&lt;/groupId&gt;
---       &lt;artifactId&gt;cocoon-forms-impl&lt;/artifactId&gt;
---       &lt;version&gt;1.0.0-RC1&lt;/version&gt;
+++   &lt;groupId&gt;org.apache.cocoon&lt;/groupId&gt;
+++   &lt;artifactId&gt;cocoon-forms-impl&lt;/artifactId&gt;
+++   &lt;version&gt;1.1.0&lt;/version&gt;
--- <p>Move in the <tt>simple-sample</tt> directory and build the block
to ensure
--- the playing field is set appropriately.</p>
+++ <p>Build the block to ensure everything is set correctly:</p>
    <pre>mvn install</pre>
--- <p>To access resources hold in the fomrs-impla and ajax-impl blocks, the Servlet
--- Service Framework  has to be instructed to fine them. Hence, open
--- <tt>src/main/resources/META-INF/cocoon/spring/servlet-service.xml</tt> and
--- the following in the<tt> &lt;servlet:context&gt;</tt> element:</p>
+++ <p>To access resources held in the cocoon-forms-impl and cocoon-ajax-impl
+++ blocks, the Servlet Service Framework  has to be told how to find them. Hence,
+++ open:</p>
--- <pre>&lt;servlet:connections&gt;
---   &lt;entry key="ajax" value-ref="org.apache.cocoon.ajax.impl.servlet"/&gt;
---   &lt;entry key="forms" value-ref="org.apache.cocoon.forms.impl.servlet"/&gt;
--- &lt;/servlet:connections&gt;</pre>
+++ <p><tt>src/main/resources/META-INF/cocoon/spring/block-servlet-service.xml</tt>
+++ </p>
+++ <p>Find the following line:</p>
+++ <pre>&lt;servlet:context mount-path="/cformexample" context-path="blockcontext:/cformexample/"/&gt;
+++ </pre>
+++ <p>and change it to look like this:</p>
+++ <pre>&lt;servlet:context mount-path="/cformexample" context-path="blockcontext:/cformexample/"&gt;
+++   &lt;servlet:connections&gt;
+++     &lt;entry key="ajax" value-ref="org.apache.cocoon.ajax.impl.servlet"/&gt;
+++     &lt;entry key="forms" value-ref="org.apache.cocoon.forms.impl.servlet"/&gt;
+++   &lt;/servlet:connections&gt;
+++ &lt;/servlet:context&gt;
+++ </pre>
    <h1>Create a form definition file</h1>
    <p>Below the form definition file is displayed,
(189 equal lines skipped)
    <h1>Add some pipelines to the sitemap</h1>
--- <p>The sitemap.xmap has to be modified as well:</p>
+++ <p>The sitemap.xmap has to be modified (located in: src\main\resources\COB-INF):
+++ </p>
--- <p>First, an i18n dictionary has to be definied:</p>
+++ <p>First, an i18n dictionary has to be defined:</p>
    <pre>  &lt;map:components&gt;
        &lt;map:transformers default="xslt"&gt;
(39 equal lines skipped)
            &lt;map:generate type="jx" src="resource/internal/registration_success.jx"/&gt;
---     &lt;/map:pipeline</pre>
+++     &lt;/map:pipeline&gt;</pre>
    <p>Note the following things:</p>
(2 equal lines skipped)
    forms catalogue does not have to be the default one, but here it is the only one
    and thus the default.</li>
    <li>In the <tt>map:flow</tt> tag our flowscript file is NOT declared,
--- Cocoon loads automatically what's in the <tt>flow</tt> directory.</li>
+++ Cocoon automatically loads whatever is in the <tt>flow</tt> directory.</li>
    <li>Then we have the pipelines:</li>
    <li>The first two are for managing the flowscript: when someone hits the
(9 equal lines skipped)
    javascript libraries, CSS files and images.</li>
    <li>Resources (XSL files, CSS, images, etc.) defined in the forms-impl and
    ajax-impl blocks are provided to this block by the Servlet Service Framework
--- (look at the paramters given to <tt>forms-samples-styling.xsl</tt>).</li>
+++ (look at the parameters given to <tt>forms-samples-styling.xsl</tt>).</li>
(57 equal lines skipped)
    <p>Direct your browser to:</p>
--- <pre>http://localhost:8888/simple-sample/registration
+++ <pre>http://localhost:8888/cformexample/registration
    <p>Try entering incorrect data and see what it does.</p>
(4 equal lines skipped)
    a simple form (though notice you didn't have to write any Java for all of this,
    nor to restart Cocoon), but adding more complexity to the form is now simply a
    matter of adding more widgets, custom validation logic, event handlers, etc. To
--- have a feel for the power of CForms, take a look at the examples included
+++ get a feel for the power of CForms, take a look at the examples included
    included in the Forms block.</p>
(1 equal lines skipped)

View raw message