[DAISY] Updated: A Simple Example

[email protected]
Newsgroups gmane.text.xml.cocoon.documentation
Message-ID <[email protected]>
A document has been updated:

http://cocoon.zones.apache.org/daisy/documentation/478.html

Document ID: 478
Branch: main
Language: default
Name: A Simple Example (unchanged)
Document Type: Cocoon Document (unchanged)
Updated on: 3/14/08 10:06:29 AM
Updated by: Luca Morandini

A new version has been created, state: draft

Parts
=====

Content
-------
This part has been updated.
Mime type: text/xml (unchanged)
File name:  (unchanged)
Size: 13839 bytes (previous version: 12210 bytes)
Content diff:
(6 equal lines skipped)
    CForms and flowscript. We will follow to following steps:</p>
    
    <ol>
+++ <li>Create a block for this sample</li>
    <li>Create a form definition file</li>
    <li>Create a template file</li>
    <li>Write a bit of flowscript</li>
    <li>Add some pipelines to the sitemap</li>
    </ol>
    
--- <p>You can try this sample out on a default Cocoon install. In the webapp
--- directory (build/webapp), create a new subdirectory, for example called
--- <tt>myformtest</tt>. In there, create the files as outlined in this sample.</p>
--- 
    <p>Here is a screenshot of the form we're going to create:</p>
    
    <p align="center"><img src="daisy:350"/></p>
    
+++ <h1>Create a block</h1>
+++ 
+++ <p>This has been covered in the tutorial, but it won't hurt to recall this Maven
+++ goal:</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 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>
+++ 
+++ <p>Edit the <tt>simple-sample/pom.xml</tt> file and add the support for Cocoon
+++ Forms:</p>
+++ 
+++ <pre>&lt;dependency&gt;
+++       &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;/dependency&gt;
+++ </pre>
+++ 
+++ <p>Move in the <tt>simple-sample</tt> directory and build the block to ensure
+++ the playing field is set appropriately.</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 add
+++ the following in the<tt> servlet-context</tt> element:</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>
+++ 
    <h1>Create a form definition file</h1>
    
    <p>Below the form definition file is displayed,
--- <tt>registration_definition.xml</tt>. This lists all the widgets in the form,
--- together with their configuration information.</p>
+++ <tt>registration_definition.xml</tt> (to be put under
+++ <tt>src/main/resources/COB-INF/resource/external</tt> directory). This lists all
+++ the widgets in the form, together with their configuration information:</p>
    
--- <pre>&lt;fd:form
+++ <pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+++ &lt;fd:form
      xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"&gt;
    
      &lt;fd:widgets&gt;
(68 equal lines skipped)
    <h1>Create a template file</h1>
    
    <p>Here is the template for our registration form example,
--- <tt>registration_template.xml</tt>:</p>
+++ <tt>registration_template.xml</tt> (to be put under
+++ <tt>src/main/resources/COB-INF/resource/external</tt> directory):</p>
    
--- <pre>&lt;html xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
+++ <pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
+++ &lt;html xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
      xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
      xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"&gt;
    
(4 equal lines skipped)
      &lt;/head&gt;
      &lt;body&gt;
        &lt;h1&gt;Registration&lt;/h1&gt;
---     &lt;ft:form-template action="#{$continuation/id}.continue" method="POST"&gt;
+++     &lt;ft:form-template action="#{$cocoon/continuation/id}.continue" method="POST"&gt;
          &lt;ft:widget-label id="name"/&gt;
          &lt;ft:widget id="name"/&gt;
          &lt;br/&gt;
(58 equal lines skipped)
    is based on the concept of continuations. If you don't know yet about
    continuations and flowscript, <a href="daisy:517">learn about it here</a>.</p>
    
--- <p>Here's the flowscript for our example, <tt>registration.js</tt>:</p>
+++ <p>Here's the flowscript for our example, <tt>registration.js</tt> (put it under
+++ <tt>src/main/resources/COB-INF/flow</tt>):</p>
    
    <pre>cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js");
    
(154 equal lines skipped)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.