A document has been updated:
http://cocoon.zones.apache.org/daisy/legacydocs/579.html
Document ID: 579
Branch: main
Language: default
Name: Creating and Using Actions (unchanged)
Document Type: Document (unchanged)
Updated on: 10/4/05 12:49:16 PM
Updated by: Helma van der Linden
A new version has been created, state: publish
Parts
=====
Content
-------
This part has been updated.
Mime type: text/xml (unchanged)
File name: (unchanged)
Size: 11240 bytes (previous version: 11270 bytes)
Content diff:
(17 equal lines skipped)
complex as you need. The Action is the proper place to handle form
processing
and even dynamic navigation. The Action is differentiated from the other
sitemap
components (Generator, Transformer, Serializer and Reader) primarily by the
fact
--- that it does not produce any display data.
--- <a href="userdocs/concepts/actions.txt">actions.txt</a> contains excerpts
from
--- discussions on the cocoon-dev mailing list regarding Actions.</p>
+++ that it does not produce any display data. <a
href="daisy:726">actions.txt</a>
+++ contains excerpts from discussions on the cocoon-dev mailing list regarding
+++ Actions.</p>
<h2>When to use an Action instead of XSP</h2>
(3 equal lines skipped)
display. For instance, we will use a multipage form. In XSP the logic to
handle
the results for one page have to be implemented in the following page.</p>
--- <pre>
--- <xsp:logic>
+++ <pre><xsp:logic>
// handle the previous page's values.
String name = <xsp-request:get-parameter name="name"/>;
String password = <xsp-request:get-parameter name="password"/>;
(48 equal lines skipped)
performing something very simple here, but you can get more complex examples
from the Cocoon code-base.</p>
--- <pre>
--- package test;
+++ <pre>package test;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.acting.AbstractAction;
(30 equal lines skipped)
<h3>Defining the Action</h3>
--- <pre>
--- <map:actions>
+++ <pre><map:actions>
<map:action name="hello-world" src="test.HelloWorldAction"/>
</map:actions>
</pre>
<h3>Using the Action</h3>
--- <pre>
--- <map:match pattern="file">
+++ <pre><map:match pattern="file">
<map:act type="hello-world">
<map:generate type="serverpages" src="{world}_world.xsp"/>
</map:act>
(6 equal lines skipped)
Also, the file <tt>hello_world.xsp</tt> can use the request attribute
<tt>hello</tt> to produce the value <tt>world</tt>.</p>
--- <pre>
--- <para>Hello <xsp-request:get-attribute
name="hello"/>.</para>
+++ <pre><para>Hello <xsp-request:get-attribute
name="hello"/>.</para>
</pre>
<h2>Communication between Sitemap and Action</h2>
(3 equal lines skipped)
Action and the Action can return a Map object with new values which can be
used
in the sitemap.</p>
--- <pre>
--- <map:match pattern="file">
+++ <pre><map:match pattern="file">
<map:act type="hello-world" src="optional src">
<!-- and here come the parameters: -->
<map:parameter name="first parameter" value="test"/>
(8 equal lines skipped)
top of it. The other Map objects are still accessible through a path
expression.
</p>
--- <pre>
--- <map:match pattern="*">
+++ <pre><map:match pattern="*">
<map:act type="validate-session">
<map:generate type="serverpages" src="{../1}.xsp"/>
</map:act>
(26 equal lines skipped)
parameter. The Environment looks for a request parameter with a prefix
"cocoon-action-" followed by an action name.</p>
--- <pre>
--- <input type="submit" name="cocoon-action-ACTIONNAME" value="click here
to do something">
+++ <pre><input type="submit" name="cocoon-action-ACTIONNAME" value="click
here to do something">
</pre>
<p class="note">The orginal "cocoon-action" syntax is deprecated but still
(8 equal lines skipped)
<p>So far let's have a look at at possible action set definition:</p>
--- <pre>
--- <map:action-sets>
+++ <pre><map:action-sets>
<map:action-set name="shop-actions">
<map:act type="session-invalidator" action="logoff"/>
<map:act type="session-validator"/>
(10 equal lines skipped)
<p>And this is a possible pipeline snipped which uses this action set:</p>
--- <pre>
--- <map:match pattern="*">
+++ <pre> <map:match pattern="*">
<map:act set="shop-actions"> <--- HERE -->
<map:generate type="serverpages" src="docs/xsp/{nextpage}.xsp"/>
<map:transform src="stylesheets/page2html.xsl"/>
(34 equal lines skipped)
Fields
======
no changes
Links
=====
no changes
Custom Fields
=============
no changes
Collections
===========
no changes