You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Alexander Daniel <al...@gmx.at> on 2007/05/01 02:54:09 UTC

Re: cookie-selector

> Is there a way to use the cookie-selector to check if a cookie  
> exist, whatever value it has.
No there isn't. The CookieSelector class returns false when a cookie  
does not exist, i.e. map:otherwise will be executed. You would need  
to know all possible values of the cookie to be sure that  
map:otherwise means cookieDoesNotExist. An example:

     <map:select type="cookie-selector">
         <map:parameter name="cookie-name" value="myCookieID"/>
         <map:when test="">
             <map:generate src="cookieIsEmpty.xml"/>
         </map:when>
         <map:when test="value1">
             <map:generate src="cookieEqualsValue1.xml"/>
         </map:when>
         <map:when test="value2">
             <map:generate src="cookieEqualsValue2.xml"/>
         </map:when>
	...
         <map:otherwise>
             <map:generate src="cookieDoesNotExist.xml"/>
         </map:otherwise>
     </map:select>


To test for cookieDoesNotExist or cookieIsEmpty you can use the  
cookie input module:

     <map:select type="parameter">
         <map:parameter name="parameter-selector-test"  
value="{cookie:myCookieID}"/>
         <map:when test="">
             <map:generate src="cookieIsEmptyOrDoesNotExist.xml"/>
         </map:when>
         <map:otherwise>
             <map:generate src="cookieHasValue.xml"/>
         </map:otherwise>
     </map:select>

When your application is fine with the same behavior for an empty  
cookie as for a non-existing cookie you can go with this solution.


I think that for testing cookieDoesNotExist without cookieIsEmpty a  
new selector or input module is necessary.

Alex


On 26.04.2007, at 16:32, Lionel Barth wrote:
> Hi,
>
> Is there a way to use the cookie-selector to check if a cookie  
> exist, whatever value it has.
>
> I tried :
>
>   <map:select type="cookie-selector">
>     <map:parameter name="cookie-name" value="myCookieID"/>
>     <map:when test="">
>       <map:generate src="nothing.xml"/>
>     </map:when>
>     <map:otherwise>
>       <map:generate type="wsproxy" src="{global:ws-url}Id= 
> {request:cookieMap/myCookieID/value}"/>
>     </map:otherwise>
>   </map:select>
>
> but it works if the cookie exist and has an empty value, not if the  
> cookie does not exist.
>
> Regards,
> Lionel
>
>
>
> ---------------------------------------------------------------------
> 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: cookie-selector

Posted by Lionel Barth <lb...@hachette-livre.fr>.
Alexander,

The solution with the cookie input module works perfectly.

Thanks a lot,
Lionel

Alexander Daniel a ecrit le 1/05/07 2:54:
>> Is there a way to use the cookie-selector to check if a cookie exist, 
>> whatever value it has.
> No there isn't. The CookieSelector class returns false when a cookie 
> does not exist, i.e. map:otherwise will be executed. You would need to 
> know all possible values of the cookie to be sure that map:otherwise 
> means cookieDoesNotExist. An example:
>
>     <map:select type="cookie-selector">
>         <map:parameter name="cookie-name" value="myCookieID"/>
>         <map:when test="">
>             <map:generate src="cookieIsEmpty.xml"/>
>         </map:when>
>         <map:when test="value1">
>             <map:generate src="cookieEqualsValue1.xml"/>
>         </map:when>
>         <map:when test="value2">
>             <map:generate src="cookieEqualsValue2.xml"/>
>         </map:when>
>     ...
>         <map:otherwise>
>             <map:generate src="cookieDoesNotExist.xml"/>
>         </map:otherwise>
>     </map:select>
>
>
> To test for cookieDoesNotExist or cookieIsEmpty you can use the cookie 
> input module:
>
>     <map:select type="parameter">
>         <map:parameter name="parameter-selector-test" 
> value="{cookie:myCookieID}"/>
>         <map:when test="">
>             <map:generate src="cookieIsEmptyOrDoesNotExist.xml"/>
>         </map:when>
>         <map:otherwise>
>             <map:generate src="cookieHasValue.xml"/>
>         </map:otherwise>
>     </map:select>
>
> When your application is fine with the same behavior for an empty 
> cookie as for a non-existing cookie you can go with this solution.
>
>
> I think that for testing cookieDoesNotExist without cookieIsEmpty a 
> new selector or input module is necessary.
>
> Alex
>
>
> On 26.04.2007, at 16:32, Lionel Barth wrote:
>> Hi,
>>
>> Is there a way to use the cookie-selector to check if a cookie exist, 
>> whatever value it has.
>>
>> I tried :
>>
>>   <map:select type="cookie-selector">
>>     <map:parameter name="cookie-name" value="myCookieID"/>
>>     <map:when test="">
>>       <map:generate src="nothing.xml"/>
>>     </map:when>
>>     <map:otherwise>
>>       <map:generate type="wsproxy" 
>> src="{global:ws-url}Id={request:cookieMap/myCookieID/value}"/>
>>     </map:otherwise>
>>   </map:select>
>>
>> but it works if the cookie exist and has an empty value, not if the 
>> cookie does not exist.
>>
>> Regards,
>> Lionel
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>

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