You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Tomasz Bech <tb...@polbox.com> on 2003/10/02 13:15:39 UTC

[Help] redirect to different ulrs depending on the url parameter value

Hi all,
I have ulr: www.host/generalpage?addinfo=x&param1=a&param2=b
and want to redirect to different matchers defending on addinfo value.
So my idea is the request param selector:
            <map:match pattern="generalpage">
                <map:select type="request-parameter">
                    <map:parameter name="parameter-name" value="addinfo"/>
                        <map:when test="A">
!!!                            call matcher pageA !!!!
                        </map:when>
                        <map:when test="B">
!!!                            call matcher pageB !!!!
                        </map:when>
                    <map:otherwise>
!!!                            call matcher pageC !!!!
                    </map:otherwise>
                </map:select>
            </map:match>

But I cannot find a way to call another matcher.
map:call needs resource not the matcher.
map:redirect-to works but forget about parameters.
So how to do it with map:selector? Or how to do it at all?
   (Cocoon 2.0.3)
       Tomasz Bech



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


Re: [Help] redirect to different ulrs depending on the url parameter value

Posted by Christian Haul <ha...@informatik.tu-darmstadt.de>.
Tomasz Bech wrote:
> And why map:call cannot forward to another matcher?

You can nest matchers, redirect external or internal ("cocoon:" 
protocol). There are resources. And in the future, arbitrary pipeline 
fragments. BTW map:call does expand sitemap variables.

> In fact I want to do it really clean, I have one general matcher:
> <map:match pattern="*_*">

Wouldn't it be cleaner to have different pipelines than to mix them?

> which handles over 50 pages. 6 of them I have to do through request 
> param selector - of course I could copy the content of that general 
> matcher in every map:when place, but it is not the right way of 
> programming :(

So, why don't you put the common stuff into a resource?

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
     fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08


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


Re: [Help] redirect to different ulrs depending on the url parameter value

Posted by Tomasz Bech <tb...@polbox.com>.
Hmm, it is really pity that there is no way to make redirect-to with 
parameters - would solve a lot of problems (not only mine - it is 
frequently asked question).
And why map:call cannot forward to another matcher?

In fact I want to do it really clean, I have one general matcher:
<map:match pattern="*_*">

which handles over 50 pages. 6 of them I have to do through request 
param selector - of course I could copy the content of that general 
matcher in every map:when place, but it is not the right way of 
programming :(



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


Re: [Help] redirect to different ulrs depending on the url parameter value

Posted by Peter Velychko <v_...@ukr.net>.
Hello Tomasz,

You can use matchers and selectors nested in parent selector or
matcher like the following:
<map:match ...>
    <map:select type="request-parameter">
        <map:parameter name="parameter-name" value="addinfo"/>
        <map:when test="A">
            <map:match ...>
            ...
            </map:match>
        </map:when>
        <map:when test="A">
            <map:select ...>
            ...
            </map:select>
        </map:when>
        ...
        <map:otherwise>
        ...
        </map:otherwise>
</map:match>

(For cocoon 2.0.4, I don't know about 2.0.3) In addition to the
"request-parameter" selector you can use the "request" matcher that
matches to request parameters also (see the
class org.apache.cocoon.matching.RequestParameterMatcher)
 <map:match type="request" pattern="dest">
     ...
 </map:match>
 
One more way is to use action to analize request parameters and
selector to switch among value resulted by action
<map:act type-"...">
    <map:select type="parameter">
        <map:parameter name="parameter-selector-test"
          value="{param-name-in-the-map-resulted-by-action}"/>
        <map:when test="AB">
            ...
        </map:when>
        <map:when test="AC">
            ...
        </map:when>
        <map:otherwise>
            ...
        </map:otherwise>
    </map:select>
</map:act>
 

TB> Hi all,
TB> I have ulr: www.host/generalpage?addinfo=x&param1=a&param2=b
TB> and want to redirect to different matchers defending on addinfo value.
TB> So my idea is the request param selector:
TB>             <map:match pattern="generalpage">
TB>                 <map:select type="request-parameter">
TB>                     <map:parameter name="parameter-name" value="addinfo"/>
TB>                         <map:when test="A">
TB> !!!                            call matcher pageA !!!!
TB>                         </map:when>
TB>                         <map:when test="B">
TB> !!!                            call matcher pageB !!!!
TB>                         </map:when>
TB>                     <map:otherwise>
TB> !!!                            call matcher pageC !!!!
TB>                     </map:otherwise>
TB>                 </map:select>
TB>             </map:match>

TB> But I cannot find a way to call another matcher.
TB> map:call needs resource not the matcher.
TB> map:redirect-to works but forget about parameters.
TB> So how to do it with map:selector? Or how to do it at all?
TB>    (Cocoon 2.0.3)
TB>        Tomasz Bech




-- 
Best regards,
Peter Velychko                            
v_peter@ukr.net


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