cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@cocoon.zones.apache.org
Subject [DAISY] Updated: Creating and Using Actions
Date Tue, 04 Oct 2005 12:49:35 GMT
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>
--- &lt;xsp:logic&gt;
+++ <pre>&lt;xsp:logic&gt;
      // handle the previous page's values.
      String name = &lt;xsp-request:get-parameter name="name"/&gt;;
      String password = &lt;xsp-request:get-parameter name="password"/&gt;;
(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>
--- &lt;map:actions&gt;
+++ <pre>&lt;map:actions&gt;
      &lt;map:action name="hello-world" src="test.HelloWorldAction"/&gt;
    &lt;/map:actions&gt;
    </pre>
    
    <h3>Using the Action</h3>
    
--- <pre>
--- &lt;map:match pattern="file"&gt;
+++ <pre>&lt;map:match pattern="file"&gt;
      &lt;map:act type="hello-world"&gt;
        &lt;map:generate type="serverpages" src="{world}_world.xsp"/&gt;
      &lt;/map:act&gt;
(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>
--- &lt;para&gt;Hello &lt;xsp-request:get-attribute name="hello"/&gt;.&lt;/para&gt;
+++ <pre>&lt;para&gt;Hello &lt;xsp-request:get-attribute name="hello"/&gt;.&lt;/para&gt;
    </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>
--- &lt;map:match pattern="file"&gt;
+++ <pre>&lt;map:match pattern="file"&gt;
      &lt;map:act type="hello-world" src="optional src"&gt;
        &lt;!-- and here come the parameters: --&gt;
        &lt;map:parameter name="first parameter" value="test"/&gt;
(8 equal lines skipped)
    top of it. The other Map objects are still accessible through a path expression.
    </p>
    
--- <pre>
--- &lt;map:match pattern="*"&gt;
+++ <pre>&lt;map:match pattern="*"&gt;
      &lt;map:act type="validate-session"&gt;
        &lt;map:generate type="serverpages" src="{../1}.xsp"/&gt;
      &lt;/map:act&gt;
(26 equal lines skipped)
    parameter. The Environment looks for a request parameter with a prefix
    "cocoon-action-" followed by an action name.</p>
    
--- <pre>
--- &lt;input type="submit" name="cocoon-action-ACTIONNAME" value="click here to do something"&gt;
+++ <pre>&lt;input type="submit" name="cocoon-action-ACTIONNAME" value="click here
to do something"&gt;
    </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>
--- &lt;map:action-sets&gt;
+++ <pre>&lt;map:action-sets&gt;
      &lt;map:action-set name="shop-actions"&gt;
        &lt;map:act type="session-invalidator" action="logoff"/&gt;
        &lt;map:act type="session-validator"/&gt;
(10 equal lines skipped)
    
    <p>And this is a possible pipeline snipped which uses this action set:</p>
    
--- <pre>
---    &lt;map:match pattern="*"&gt;
+++ <pre>   &lt;map:match pattern="*"&gt;
        &lt;map:act set="shop-actions"&gt;     &lt;--- HERE --&gt;
         &lt;map:generate  type="serverpages" src="docs/xsp/{nextpage}.xsp"/&gt;
         &lt;map:transform src="stylesheets/page2html.xsl"/&gt;
(34 equal lines skipped)


Fields
======
no changes

Links
=====
no changes

Custom Fields
=============
no changes

Collections
===========
no changes

Mime
View raw message