cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephan Coboos <>
Subject Re: How to write request parameter into session attribute in sitemap ?
Date Fri, 01 Oct 2004 05:51:20 GMT
I think, the easiest way to do so would be to write your own simple 
action which does this.

Not tested:

import org.apache.cocoon.acting.AbstractAction;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.environment.Source;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.Session;

import java.util.Map;
import java.util.*;

public class SessionCopyAction extends AbstractAction {

    public Map act(Redirector redirector, SourceResolver resolver, Map 
        String source, Parameters parameters) throws Exception {

        // Get the name of the request parameter
        String requestParamName = parameters.getParameter("reqParamName");

        // Copy the value from the request into the session
        Request request = ObjectModelHelper.getRequest(objectModel);
        Session session =  request.getSession();

        return new HashMap();

Your sitemap should look like:

<map:match pattern="visu">
    <map:act type="sessionCopyAction">
        <map:parameter name="reqParamName" value="valdoc"/>
    <map:read src="cache/{1}.html" mime-type="text/html"/>


Willy Reinhardt wrote:

>I get a request with a parameter like ../visu?valdoc=100.01
>I would copy the value into a session attribute this during sitemap
>I am looking for something like:
><map:match pattern="visu">
>  <map:match type="request-parameter" pattern="valdoc">
>    <map:act type="session">
>        <map:parameter name="valdoc" value="{1}"/>
>    </map:act>
>    <map:read src="cache/{1}.html" mime-type="text/html"/>
>  </map:match>
>Thanks for any idea.
>To unsubscribe, e-mail:
>For additional commands, e-mail:

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

View raw message