cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Stevens" <>
Subject RE: accessing sitemap variables from an action
Date Wed, 13 Sep 2006 07:42:08 GMT
>From: Stephen Winnall <>
>Date: Tue, 12 Sep 2006 15:00:59 +0200
>I'm writing an action. It's definition is as follows:
>public Map act(Redirector redirector, SourceResolver resolver, Map  
>objectModel, String source, Parameters parameters) throws Exception {
>	...
>I call the action in the sitemap in a context similar to the following:
><map:match pattern="**">
>   <map:match pattern="*.html">
>     <map:act type="abc">
>       <map:parameter name="abc-param" value="abc-value" />
>       <!-- MY ACTION IS HERE -->
>       <map:act type="def">
>         <map:parameter name="def-param" value="def-value" />
>       </map:act>
>     </map:act>
>   </map:match>
>I want to be able to get at sitemap variables from all context levels  from 
>within my action. That means that in the invocation of 'def'  above, I want 
>to be able to access {def-param}, {../abc-param},  {../../1} and 
>{../../../1}. As far as have been able to determine,  the parameter 
>"Parameters parameters" of the 'act' method only  contains "def-param".
>Can someone point me at how to read the other parameters from within  

Define/expect another named parameter in your action, and in the sitemap 
specify {../../1} or whatever as its value. e.g.

       <map:act type="def">
         <map:parameter name="def-param" value="def-value" />
         <map:parameter name="other-param" value="{../../1}" />

As you have seen, only the parameters directly inside the map:act are passed 
to the action.  The values with {../whatever} are a sitemap notation.  
Trying to lookup a value from a parent map makes no sense in the action 
itself - how would it know in what context it was used, or if it was even 
used inside the scope of another map?  Or suppose you inserted another 
action (e.g. LocaleAction) into the sitemap between the matcher and your 
action - if your action relied on a specific path to the value, it would 
break as it would now be looking at the wrong level...


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message