cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morgan Roderick <mor...@wingercom.net>
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. 
http://mailman.real-time.com/pipermail/cocoon-users/2001-September/019125.html

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.

Sincerely
Morgan Roderick

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


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

*** HelloWorldAction.java ***
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. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message