cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morgan Roderick <>
Subject [C2] Actions - Request for example
Date Thu, 01 Nov 2001 11:38:36 GMT
Hi All

I am in the process of understanding how actions work in C2 and have found the "Action vs
Request" thread started by Tobias Luikard on Mon, 17 Sep 2001 very useful, it has gotten me
a lot closer to understanding Actions.

I am, however, lacking that final piece of the puzzle that ties it all together. An example!

Has anyone got a SIMPLE working example of an action, that they would post to the list?
Preferably something that returns XML that can be used in XSL/serializer.

I have managed to create an action that:
- compiles
- does not generate a ClassNotFoundException (by deploying it to /WEB-INF/classes/)

I cannot seem to understand how to get any output from the action out on the screen, to a
serializer, etc.

What really bugs me is that the hello_world.xsp does not really show up anywhere.

Morgan Roderick

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

*** Pipeline ***
<map:match pattern="file">
    <map:act type="hello-world">
        <map:generate type="serverpages" src="{world}_world.xsp"/>

*** ***
package test;

import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.acting.AbstractAction;
import org.apache.cocoon.Constants;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.SourceResolver;
import java.util.*;
import org.apache.cocoon.environment.Request;
import org.xml.sax.EntityResolver;

public class HelloWorldAction extends AbstractAction {
  public Map act (Redirector redirector, 
                  SourceResolver resolver, 
                  Map objectModel, 
                  String source, 
                  Parameters params) {
    Map sitemapParams = new HashMap();
    sitemapParams.put("world", "hello");

    Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);

    request.setAttribute("hello", "world");

    return sitemapParams;

Please check that your question has not already been answered in the
FAQ before posting. <>

To unsubscribe, e-mail: <>
For additional commands, e-mail: <>

View raw message