You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Ilya A. Kriveshko" <il...@kaon.com> on 2002/08/06 18:30:55 UTC

Q: Dynamically choosing action type.

Hello,

I am writing an application using Cocoon2. My application can display 
certain entities, as well as perform certain actions on those entities 
prior to displaying them.

I decided to use the following scheme for the URIs:
/(entity-name)-(action)?entity_id=1&other_args=other_values

So, I would like to have the following entries in my sitemap:

    <!-- *-view is a special URI that warrants its own pipeline -->
    <map:pipeline>
      <map:match pattern="*-view">
        <map:generate type="serverpages" src="{1}.xsp"/>
        <map:transform src="{1}-ui.xsl"/>
        <map:transform src="ui2html.xsl"/>
        <map:serialize type="html"/>
      </map:match>
    </map:pipeline>

    <!-- Other *-* URIs are used to trigger actions and then redirect to 
the *-view -->
    <map:pipeline>
      <map:match pattern="*-*">
        <map:act type="myapp-{1}-{2}"/>
        <map:redirect-to uri="cocoon:/{1}-view"/>
      </map:match>
    </map:pipeline>

Of course, the latter doesn't work, since the value of map:act/@type 
does not expand the parameters {1} and {2}. I can only do the following:

    <map:pipeline>
      <map:match pattern="entity1-action1">
        <map:act type="myapp-entity1-action1"/>
        <map:redirect-to uri="cocoon:/entity1-view"/>
      </map:match>
      <map:match pattern="entity1-action2">
        <map:act type="myapp-entity1-action2"/>
        <map:redirect-to uri="cocoon:/entity1-view"/>
      </map:match>
      <map:match pattern="entity2-action1">
        <map:act type="myapp-entity2-action1"/>
        <map:redirect-to uri="cocoon:/entity2-view"/>
      </map:match>
      <!-- etc... -->
    </map:pipeline>

I will have quite a few entities and quite a few actions. It would be 
nice if I didn't have to specify a matcher for every entity/action 
combination, but instead be able to use {#}-style attribute expansion in 
the map:act/@type  attribute. I understand that this creates the 
possibility of a runtime error where only initialization-time error was 
possible before, however it would be very convenient, at least in my case.

I would like to be able to add actions and entities without having to 
populate the pipelines for every combination.

Any suggestion as to how I should go about it would be greatly appreciated.
--
Ilya

P.S.: I have been away from using Cocoon(1) since about 2.5 years ago, 
and am very impressed by the amount of effort that has gone into it 
since back then and by the wealth of functionality that was added. Keep 
up the good work! Thanks!



---------------------------------------------------------------------
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: Q: Dynamically choosing action type.

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 06.Aug.2002 -- 02:45 PM, Ilya A. Kriveshko wrote:
> Ilya A. Kriveshko wrote:
> My previous question still stands:
> 
> >Can I write a custom dispatcher class that would look at the request 
> >and then decide which action from the set should get executed, and 
> >install that dispatcher for a particular action-set in the sitemap?
> 
> I wish there were a way to call setAction() on Environment or some other 
> alternative way to specify the action, other than having a 
> pre-determined request parameter. Maybe even dynamically inside another 
> action, so that one can have several tiers of action sets, one executed 
> after another and the former determining the action to execute in the 
> latter.
> 
> Is there already a way to do this that I overlooked?

I believe that with compiled sitemap as well as treeprocessor you
can't do it through the sitemap.

However, you could write an action that dispatches other
actions. Afterall, actions are just avalon components and they share
the same component manager to some extent. Your action would need to
be composable to get the component manager instance needed.

But watchout: This custom action needs to be declared in the very
sitemap you want to use it, since this way it would inherit all
components from managers of ancestor sitemaps. Obviously, as long as
you don't access components declared on subsitemaps this could be
relaxed to declare the action on the same level or below the one your
other actions are declared.

If you were using the flow layer in 2.1-dev, you could do it from
there. 

	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

---------------------------------------------------------------------
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: Q: Dynamically choosing action type.

Posted by "Ilya A. Kriveshko" <il...@kaon.com>.
Ilya A. Kriveshko wrote:

> I'm a bit confused as to how it is determined which action from the 
> set gets executed. It appears to somehow be related to 
> "cocoon-action-*" parameter, but I can't seem to find how the 
> selection scheme works. Can you point me to the .java file where the 
> selection happens?

Ok, I'm not confused anymore. I found the file:
org/apache/cocoon/components/treeprocessor/sitemap/ActionSetNode.java

It appears that "cocoon-action-" prefix is hard-coded in 
org/apache/cocoon/Constants.java. It is used by HttpEnvironment in 
determining the environment's action, and that's what is matched against 
the names of the actions in the set.

My previous question still stands:

> Can I write a custom dispatcher class that would look at the request 
> and then decide which action from the set should get executed, and 
> install that dispatcher for a particular action-set in the sitemap?

I wish there were a way to call setAction() on Environment or some other 
alternative way to specify the action, other than having a 
pre-determined request parameter. Maybe even dynamically inside another 
action, so that one can have several tiers of action sets, one executed 
after another and the former determining the action to execute in the 
latter.

Is there already a way to do this that I overlooked?

Thank you!
--
Ilya








---------------------------------------------------------------------
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: Q: Dynamically choosing action type.

Posted by "Ilya A. Kriveshko" <il...@kaon.com>.
>
>
>>I decided to use the following scheme for the URIs:
>>/(entity-name)-(action)?entity_id=1&other_args=other_values
>>
>
>Maybe action-sets could help here. Although they don't really match
>your scheme.
>
I'm a bit confused as to how it is determined which action from the set 
gets executed. It appears to somehow be related to "cocoon-action-*" 
parameter, but I can't seem to find how the selection scheme works. Can 
you point me to the .java file where the selection happens? Can I write 
a custom dispatcher class that would look at the request and then decide 
which action from the set should get executed, and install that 
dispatcher for a particular action-set in the sitemap?

I would like the action selection to be based on the servlet path and 
not based on request parameters (especially not based on a parameter 
with a pre-determined name, like "cocoon-action-*"). While it is not 
essential, it does simplify other parts of my application.

Thanks!
--
Ilya




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


Upgrading 1.8.2 to 2.0.3

Posted by Yrjö Mäenpää <yr...@dlc.fi>.
Hi

I have a product site using Cocoon 1.8.2. Now I want to upgrade
to version 2.0.3, but hesitate somewhat, as I am not sure how
much downtime I can tolerate when configuring the 2.0.3.

Is it possible to have both versions in the same server, so I could
prepare the new one before removing the old?

Any advise what to consider when upgrading will be most welcomed.

thanks


---------------------------------------------------------------------
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: Q: Dynamically choosing action type.

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 06.Aug.2002 -- 12:30 PM, Ilya A. Kriveshko wrote:
> Hello,
> 
> I am writing an application using Cocoon2. My application can display 
> certain entities, as well as perform certain actions on those entities 
> prior to displaying them.
> 
> I decided to use the following scheme for the URIs:
> /(entity-name)-(action)?entity_id=1&other_args=other_values

Maybe action-sets could help here. Although they don't really match
your scheme.

	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

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