You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Willy Reinhardt <wr...@novell.com> on 2004/09/30 19:44:40 UTC

How to write request parameter into session attribute in sitemap ?

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


Re: How to write request parameter into session attribute in sitemap ?

Posted by Stephan Coboos <cr...@gmx.net>.
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


Re: How to write request parameter into session attribute in sitemap ?

Posted by Andreas Hartmann <an...@apache.org>.
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>

You can use the request parameter input module:

<map:act type="session">
   <map:parameter name="valdoc=" value="{request-param:valdoc}"/>
</map:act>


-- Andreas


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


Re: How to write request parameter into session attribute in sitemap ?

Posted by pguillard <pg...@soociety.com>.
Hi,

Try this :
<map:act type="session-propagator">
<map:parameter name="group" value="{request-param:visu}"/>
</map:act>
Phil


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