cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephan Coboos <cromo...@gmx.net>
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 
objectModel,
        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();
       
        session.setAttribute(requestParamName, 
request.getParameter(requestParamName));

        return new HashMap();
    }
}

Your sitemap should look like:

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



Regards
Stephan

Willy Reinhardt wrote:

>Hi,
>I get a request with a parameter like ../visu?valdoc=100.01
>I would copy the value into a session attribute this during sitemap
>proccess.
>
>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>
></map:match>
>
>Thanks for any idea.
>
>Willy
>
>
>
> 
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>  
>



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


Mime
View raw message