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 an Action
Date Thu, 25 Aug 2005 16:55:17 GMT
A document has been updated:

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

Document ID: 676
Branch: main
Language: default
Name: Creating an Action (unchanged)
Document Type: Document (unchanged)
Updated on: 8/25/05 4:55:12 PM
Updated by: Berin Loritsch

A new version has been created, state: publish

Parts
=====
Content
-------
This part has been updated.
Mime type: text/xml (unchanged)
File name:  (unchanged)
Size: 6187 bytes (previous version: 6223 bytes)
Content diff:
(47 equal lines skipped)
    </ul>
    
    <p>Most of these items were covered in the
--- <a href="daisy:673">SitemapModelComponent Contracts</a> documentation.  The
only
--- item not covered so far is the Redirector.  The
+++ <a href="daisy:673">SitemapModelComponent Contracts</a> documentation. The
only
+++ item not covered so far is the Redirector. The
    <a href="http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/environment/Redirector.html">org.apache.cocoon.environment.Redirector</a>
    provides an interface to send a redirect so tha the browser requests a new
    document and we stop processing this one.</p>
(4 equal lines skipped)
    <h2>Creating the Action</h2>
    
    <p>It's not too hard to create an Action, but it can be difficult to keep track
--- of what you are expecting the Sitemap to give you and what you give the
--- Sitemap.  As long as the purpose for your action is small and focused we can
--- keep everything straight.  What we are going to do here is create a "theming"
--- action.  The responsibility of the action is to select the stylesheet for the
--- theme, but if the source is "xml" then we don't apply a stylesheet at all.  It's
--- actually not too difficult to perform.  First let's set up our Sitemap:</p>
+++ of what you are expecting the Sitemap to give you and what you give the Sitemap.
+++ As long as the purpose for your action is small and focused we can keep
+++ everything straight. What we are going to do here is create a "theming" action.
+++ The responsibility of the action is to select the stylesheet for the theme, but
+++ if the source is "xml" then we don't apply a stylesheet at all. It's actually
+++ not too difficult to perform. First let's set up our Sitemap:</p>
    
    <pre>&lt;map:choose pattern="**.xhtml"
      &lt;map:generate src="{1}.xml"/&gt;
(4 equal lines skipped)
    &lt;/map:choose/&gt;
    </pre>
    
--- <p>The plan is to use a parameter passed in to determine the theme.  That means
+++ <p>The plan is to use a parameter passed in to determine the theme. That means
    we aren't going to need the Source or SourceResolver parameters to perform our
--- processing.  We will need to extract the request parameter "theme" and interpret
--- it.  If "theme" has the value "xml" we don't do any transformations.  If "theme"
--- doesn't exist, we will provide a default value.  And lastly, we will copy the
+++ processing. We will need to extract the request parameter "theme" and interpret
+++ it. If "theme" has the value "xml" we don't do any transformations. If "theme"
+++ doesn't exist, we will provide a default value. And lastly, we will copy the
    request parameter "theme" to the returned Map so it is accessible inside.</p>
    
    <p>First the boiler plate code:</p>
(20 equal lines skipped)
    }
    </pre>
    
--- <p>Now we can concentrate on the method itself.  First things first, we need to
--- get the "theme" request parameter.  We do this by accessing the Request object
+++ <p>Now we can concentrate on the method itself. First things first, we need to
+++ get the "theme" request parameter. We do this by accessing the Request object
    from the object model:</p>
    
    <pre>Request request = RequestObjectModelHelper.getRequest( objectModel );
    String theme = request.getParameter("theme");
    </pre>
    
--- <p>Ok, so we have the theme from the request object.  Now lets check if it is
--- empty and provide a default value if it isn't.</p>
+++ <p>Ok, so we have the theme from the request object. Now lets check if it is
+++ empty and provide a default value if it is empty..</p>
    
    <pre>if ( null == theme || theme.length() == 0 )
    {
        theme = DEFAULT_THEME;
    }
    </pre>
    
--- <p>Next, let's check to see if the theme is the "xml" theme.  We'll do it in a
--- way that does not matter what case the "xml" value is.  We return <tt>null</tt>
+++ <p>Next, let's check to see if the theme is the "xml" theme. We'll do it in a
+++ way that does not matter what case the "xml" value is. We return <tt>null</tt>
    in this case so that the transformer in the sitemap snippet above does not get
    added to the pipeline.</p>
    
(4 equal lines skipped)
    </pre>
    
    <p>Now we can assume that the value we have in the parameter "theme" is the name
--- of a valid theme.  We aren't going to do validation here, that's something you
+++ of a valid theme. We aren't going to do validation here, that's something you
    can have if you have inclination.</p>
    
    <pre>Map returnValues = new HashMap();
(2 equal lines skipped)
    return returnValues;
    </pre>
    
--- <p>That's it!  We're done.  We have an action that does not have to be pooled,
+++ <p>That's it! We're done. We have an action that does not have to be pooled,
    selects a theme, provides a default, and does not apply formatting if the theme
    is "xml".</p>
    
(2 equal lines skipped)


Fields
======
no changes

Links
=====
no changes

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

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

Mime
View raw message