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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to