cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ilya A. Kriveshko" <i...@kaon.com>
Subject Q: Dynamically choosing action type.
Date Tue, 06 Aug 2002 16:30:55 GMT
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:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message