You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Yvan Peter <Yv...@univ-lille1.fr> on 2002/09/12 08:39:24 UTC

putting a request param in session and using it in the sitemap

    Hello,

    Here is the behavior i would like to achieve in the sitemap :

    A first access will be with an URL of that pattern :
      http://localhost/login?device={Voice, WAP or Web}

    Then the device parameter is not given anymore and of course, i need
to remember it to choose the appropriate XSL...

    I did not find how to put a request parameter in a session and get 
it back latter from that session for use in the sitemap.

    Here is the "best" solution i could achieve after a whole day
trying to fill in the blanks without success...

   <map:match pattern="test/*">
     <map:match type="request-parameter" pattern="device">
       <!-- how to create the session and put device in it ? -->
       <map:redirect-to uri="cocoon:/good-test/{../1}" />
     </map:match>
     <!-- how to extract the value from session rather than hard code a 
default value for the test ? -->
     <map:redirect-to uri="cocoon:/good-test/{1}">
       <map:parameter name="device" value="Web" />
     </map:redirect-to>
   </map:match>

   <map:match pattern="good-test/*">
     <map:generate src="test/{1}.xml" />
     <map:select type="request-parameter">
       <map:parameter name="parameter-name" value="device" />
       <map:when test="Wap">
         <map:transform src="test/XML2WML.xsl" />
       </map:when>
       <map:when test="Voix">
           <map:transform src="test/XML2VXML.xsl" />
       </map:when>
       <map:otherwise>
         <map:transform src="test/XML2HTML.xsl" />
       </map:otherwise>
     </map:select>
     <map:serialize />
   </map:match>

   I used a redirection because i could not even imagine doing this in 
one pipeline...

    Any help in that matter would be greatly appreciated :-)

    Yvan

-- 
------------------------------------------------------------------
| Yvan Peter                    | phone (33) 3.20.43.32.64       |
| CUEEP/Laboratoire TRIGONE     | fax   (33) 3.20.43.32.79       |
| Bat. B6                       | mail Yvan.Peter@univ-lille1.fr |
| Cite Scientifique             |                                |
| 59655 Villeneuve d'Ascq Cedex |                                |
------------------------------------------------------------------



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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


Re: putting a request param in session and using it in the sitemap

Posted by Antonio Gallardo Rivera <ag...@agsoftware.dnsalias.com>.
Have you tried the

SessionSelector: that is used as the Parameter selector to match against an 
arbitrary session attribute; 

More about Parameter Selector in:

Parameter Selector:
http://xml.apache.org/cocoon/userdocs/selectors/parameter-selector.html

Antonio Gallardo


El Jueves, 12 de Septiembre de 2002 00:39, Yvan Peter escribió:
>     Hello,
>
>     Here is the behavior i would like to achieve in the sitemap :
>
>     A first access will be with an URL of that pattern :
>       http://localhost/login?device={Voice, WAP or Web}
>
>     Then the device parameter is not given anymore and of course, i need
> to remember it to choose the appropriate XSL...
>
>     I did not find how to put a request parameter in a session and get
> it back latter from that session for use in the sitemap.
>
>     Here is the "best" solution i could achieve after a whole day
> trying to fill in the blanks without success...
>
>    <map:match pattern="test/*">
>      <map:match type="request-parameter" pattern="device">
>        <!-- how to create the session and put device in it ? -->
>        <map:redirect-to uri="cocoon:/good-test/{../1}" />
>      </map:match>
>      <!-- how to extract the value from session rather than hard code a
> default value for the test ? -->
>      <map:redirect-to uri="cocoon:/good-test/{1}">
>        <map:parameter name="device" value="Web" />
>      </map:redirect-to>
>    </map:match>
>
>    <map:match pattern="good-test/*">
>      <map:generate src="test/{1}.xml" />
>      <map:select type="request-parameter">
>        <map:parameter name="parameter-name" value="device" />
>        <map:when test="Wap">
>          <map:transform src="test/XML2WML.xsl" />
>        </map:when>
>        <map:when test="Voix">
>            <map:transform src="test/XML2VXML.xsl" />
>        </map:when>
>        <map:otherwise>
>          <map:transform src="test/XML2HTML.xsl" />
>        </map:otherwise>
>      </map:select>
>      <map:serialize />
>    </map:match>
>
>    I used a redirection because i could not even imagine doing this in
> one pipeline...
>
>     Any help in that matter would be greatly appreciated :-)
>
>     Yvan

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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


Re: putting a request param in session and using it in the sitemap [SOLUTION]

Posted by Yvan Peter <Yv...@univ-lille1.fr>.
   Thanks to the people who answered, it helped me building a solution.

   Here is the sitemap snippet that put a request param into a session 
and can latter retrieve it in the sitemap :

   <map:match pattern="test/*">
     <map:match type="request-parameter" pattern="device">
       <!-- if URL of type localhost/test?device="Wap" put the value of
            the parameter in session -->
       <map:act type="session-propagator">
         <map:parameter name="device" value="{1}" />
       </map:act>
       <!-- then redirect to the pipeline that does the work -->
       <map:redirect-to uri="cocoon:/good-test/{../1}" />
     </map:match>
     <map:match type="session-attribute" pattern="device">
       <!-- else find the device value in session and use it for
            redirection -->
       <map:redirect-to uri="cocoon:/good-test/{../1}?device={1}" />
     </map:match>
   </map:match>

   <map:match pattern="good-test/*">
     <map:generate src="test/{1}.xml" />
     <map:select type="request-parameter">
       <map:parameter name="parameter-name" value="device" />
       <map:when test="Wap">
         <map:transform src="test/XML2WML.xsl" />
       </map:when>
       <map:when test="Voix">
           <map:transform src="test/XML2VXML.xsl" />
       </map:when>
       <map:otherwise>
         <map:transform src="test/XML2HTML.xsl" />
       </map:otherwise>
     </map:select>
     <map:serialize />
   </map:match>

>>
>>    Hello,
>>
>>    Here is the behavior i would like to achieve in the sitemap :
>>
>>    A first access will be with an URL of that pattern :
>>      http://localhost/login?device={Voice, WAP or Web}
>>
>>    Then the device parameter is not given anymore and of course, i need
>> to remember it to choose the appropriate XSL...
>>
>>    I did not find how to put a request parameter in a session and get 
>> it back latter from that session for use in the sitemap.



-- 
------------------------------------------------------------------
| Yvan Peter                    | phone (33) 3.20.43.32.64       |
| CUEEP/Laboratoire TRIGONE     | fax   (33) 3.20.43.32.79       |
| Bat. B6                       | mail Yvan.Peter@univ-lille1.fr |
| Cite Scientifique             |                                |
| 59655 Villeneuve d'Ascq Cedex |                                |
------------------------------------------------------------------


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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


Re: putting a request param in session and using it in the sitemap

Posted by Bobby Mitchell <bo...@niac.usra.edu>.
Yvan Peter wrote:

>
>    Hello,
>
>    Here is the behavior i would like to achieve in the sitemap :
>
>    A first access will be with an URL of that pattern :
>      http://localhost/login?device={Voice, WAP or Web}
>
>    Then the device parameter is not given anymore and of course, i need
> to remember it to choose the appropriate XSL...
>
>    I did not find how to put a request parameter in a session and get 
> it back latter from that session for use in the sitemap.
>
>    Here is the "best" solution i could achieve after a whole day
> trying to fill in the blanks without success...
>
>   <map:match pattern="test/*">
>     <map:match type="request-parameter" pattern="device">
>       <!-- how to create the session and put device in it ? -->
>       <map:redirect-to uri="cocoon:/good-test/{../1}" />
>     </map:match>
>     <!-- how to extract the value from session rather than hard code a 
> default value for the test ? -->
>     <map:redirect-to uri="cocoon:/good-test/{1}">
>       <map:parameter name="device" value="Web" />
>     </map:redirect-to>
>   </map:match>
>
>   <map:match pattern="good-test/*">
>     <map:generate src="test/{1}.xml" />
>     <map:select type="request-parameter">
>       <map:parameter name="parameter-name" value="device" />
>       <map:when test="Wap">
>         <map:transform src="test/XML2WML.xsl" />
>       </map:when>
>       <map:when test="Voix">
>           <map:transform src="test/XML2VXML.xsl" />
>       </map:when>
>       <map:otherwise>
>         <map:transform src="test/XML2HTML.xsl" />
>       </map:otherwise>
>     </map:select>
>     <map:serialize />
>   </map:match>
>
>   I used a redirection because i could not even imagine doing this in 
> one pipeline...
>
>    Any help in that matter would be greatly appreciated :-)
>
>    Yvan
>
            <map:action name="req-params" 
src="org.apache.cocoon.acting.RequestParameterExistsAction"/>
            <map:action name="session-propagator" 
src="org.apache.cocoon.acting.SessionPropagatorAction"/>


                   <map:act type="req-params">
                     <map:parameter name="parameters" value="device"/>
                     <map:act type="session-propagator">
                       <map:parameter name="device" value="{device}"/>
                     </map:act>
                   </map:act>


-- 
Robert J. (Bobby) Mitchell
Systems Administrator
NASA Institute for Advanced Concepts
555A 14th St Atlanta, Ga. 30318
Phone: (404)347-9633 Fax: (404)347-9638





---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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