You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Laurent Comte <la...@oodrive.fr> on 2003/02/14 19:48:19 UTC

Using a RequestAttributeSelector

I would like to :

1/ use a servlet (servDoSomething) as a generator to generate some XML data.

2/ depending of what happened in step 1 (everything was fine or some error
   happened), I would like to set a "nextpage" attribute to say where should
   we go next :

	request.setAttribute("nextpage", "ok")
	or
	request.setAttribute("nextpage", "error")

3/ in the pipeline, I want to select the good stylesheet depending of this
   attribute. So I tried to use the RequestAttributeSelector, because i've
put
   the attribute "nextpage" in the request.



BUT, it seems that the request read by the selector is the original one (or
something like this), and my attribute is never found ...
I used the logger of the RequestAttributeSelector and it says :

"RequestAttributeSelector: Request attribute 'nextpage' not set -- failing"


So, i'de like to find a good way to select my transformer at runtime,
depending
of the result of the generator-servlet.

We can say : using a kind of "Controller" to choose the right "View",
depending
of the result of an action in the "Model".

Any ideas ?

Laurent.


============================================================================

Cocoon 2.0.4 ; J2SE 1.4.1 ; Tomcat 4.1.18 ; Win2000 SP3


<map:selector logger="sitemap.selector.request-attribute"
 	name="request-attribute"
src="org.apache.cocoon.selection.RequestAttributeSelector">
 <attribute-name>nextpage</attribute-name>
</map:selector>


<map:pipeline match="someUrl">
    <map:generate src="http://localhost:8080/web/servDoSomething" />

    <map:select type="request-attribute">
	<map:when test="ok">
	     <map:transform src="a_first_stylesheet.xsl" />
	</map:when>
	<map:otherwise>
		<map:transform src="a_second_stylesheet.xsl" />
	</map:otherwise>
    </map:select>
      <map:serialize />
</map:pipeline>


---------------------------------------------------------------------
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: Using a RequestAttributeSelector

Posted by Laurent Comte <la...@oodrive.fr>.

>let me quote a comment from the virgin cocoon sitemap:
>
><quote>
>  Since this is important, let me repeat it: Selectors are executed
>  during pipeline setup.
></quote>
>
>the same goes for matchers and actions.
>
>what this means is that the RequestAttributeSelector is done before your
>generation step in the pipeline even starts. so, yes, the selector was
>acting on the original request (someUrl in your pipeline).

Right. I thought it was the case only for actions ...



>another issue: I think it wouldn't even work when the selector would
execute
>after the generation step, because you are selecting on a request
attribute;
>but you're generating from the url, i.e. you make a request, you don't
>process it. so having the servlet set a request attribute is useless, since
>it generates a response, not a request.

Right again ...



>apart from that I wonder why you'd want an external servlet as a
controller.
>and I don't have any good idea (besides ugly stuff) how to do what you want
>to achieve.

I don't want use an external servlet as a controller, but as a generator (to
produce XML dynamically).
I'de like to found a good way to select the right "View" dynamically,
depending
of the result of the generator-servlet. It's not necessary with a servlet.
Perhaps it's not possible yet with Cocoon ?


Laurent.




---------------------------------------------------------------------
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>


AW: Using a RequestAttributeSelector

Posted by Marco Rolappe <m_...@web.de>.
hi laurent,

> -----Ursprungliche Nachricht-----
> Von: cocoon-users-return-46686-m_rolappe=web.de@xml.apache.org
> [mailto:cocoon-users-return-46686-m_rolappe=web.de@xml.apache.org]Im
> Auftrag von Laurent Comte
> Gesendet: Freitag, 14. Februar 2003 19:48
> An: cocoon-users@xml.apache.org
> Betreff: Using a RequestAttributeSelector
>
>

<snip/>

> BUT, it seems that the request read by the selector is the
> original one (or
> something like this), and my attribute is never found ...
> I used the logger of the RequestAttributeSelector and it says :
>
> "RequestAttributeSelector: Request attribute 'nextpage' not set
> -- failing"
>
>
> So, i'de like to find a good way to select my transformer at runtime,
> depending
> of the result of the generator-servlet.

let me quote a comment from the virgin cocoon sitemap:

<quote>
  Since this is important, let me repeat it: Selectors are executed
  during pipeline setup.
</quote>

the same goes for matchers and actions.

what this means is that the RequestAttributeSelector is done before your
generation step in the pipeline even starts. so, yes, the selector was
acting on the original request (someUrl in your pipeline).

another issue: I think it wouldn't even work when the selector would execute
after the generation step, because you are selecting on a request attribute;
but you're generating from the url, i.e. you make a request, you don't
process it. so having the servlet set a request attribute is useless, since
it generates a response, not a request.

apart from that I wonder why you'd want an external servlet as a controller.
and I don't have any good idea (besides ugly stuff) how to do what you want
to achieve.


---------------------------------------------------------------------
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>