Return-Path: Delivered-To: apmail-cocoon-docs-archive@www.apache.org Received: (qmail 96680 invoked from network); 4 Oct 2005 12:53:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Oct 2005 12:53:26 -0000 Received: (qmail 19719 invoked by uid 500); 4 Oct 2005 12:53:23 -0000 Delivered-To: apmail-cocoon-docs-archive@cocoon.apache.org Received: (qmail 19689 invoked by uid 500); 4 Oct 2005 12:53:23 -0000 Mailing-List: contact docs-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: docs@cocoon.apache.org List-Id: Delivered-To: mailing list docs@cocoon.apache.org Received: (qmail 19678 invoked by uid 99); 4 Oct 2005 12:53:23 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [207.7.158.203] (HELO cocoon.zones.apache.org) (207.7.158.203) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Oct 2005 05:53:23 -0700 Message-ID: <7123729.1128430175312.JavaMail.daisy@cocoon.zones.apache.org> Date: Tue, 4 Oct 2005 12:49:35 +0000 (GMT+00:00) From: daisy@cocoon.zones.apache.org To: docs@cocoon.apache.org Subject: [DAISY] Updated: Creating and Using Actions Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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. --- actions.txt contains excerpts from --- discussions on the cocoon-dev mailing list regarding Actions.

+++ that it does not produce any display data. actions.txt +++ contains excerpts from discussions on the cocoon-dev mailing list regarding +++ Actions.

When to use an Action instead of XSP

(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.

---
--- <xsp:logic>
+++ 
<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.

---
--- package test;
+++ 
package test;
    
    import org.apache.avalon.framework.parameters.Parameters;
    import org.apache.cocoon.acting.AbstractAction;
(30 equal lines skipped)
    
    

Defining the Action

---
--- <map:actions>
+++ 
<map:actions>
      <map:action name="hello-world" src="test.HelloWorldAction"/>
    </map:actions>
    

Using the Action

---
--- <map:match pattern="file">
+++ 
<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 hello_world.xsp can use the request attribute
    hello to produce the value world.

---
--- <para>Hello <xsp-request:get-attribute name="hello"/>.</para>
+++ 
<para>Hello <xsp-request:get-attribute name="hello"/>.</para>
    

Communication between Sitemap and Action

(3 equal lines skipped) Action and the Action can return a Map object with new values which can be used in the sitemap.

---
--- <map:match pattern="file">
+++ 
<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.
    

---
--- <map:match pattern="*">
+++ 
<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.

---
--- <input type="submit" name="cocoon-action-ACTIONNAME" value="click here to do something">
+++ 
<input type="submit" name="cocoon-action-ACTIONNAME" value="click here to do something">
    

The orginal "cocoon-action" syntax is deprecated but still (8 equal lines skipped)

So far let's have a look at at possible action set definition:

---
--- <map:action-sets>
+++ 
<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)
    
    

And this is a possible pipeline snipped which uses this action set:

---
---    <map:match pattern="*">
+++ 
   <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