cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marco Rolappe" <m_rola...@web.de>
Subject AW: Actions and parameters in sitemap
Date Wed, 25 Feb 2004 07:38:20 GMT
hi anna,

the <map:act> containers form kind of scopes. as illustrated by neil, you
have to reference variables from outer 'scopes' via a corresponding 'path'
expression. that whole issue is a bit... dunno. but that's one reason not to
use actions.

contrived example:

...
	<map:act type="act1"> <!-- returns a parameter 'foo' -->
		<map:act type="act2"> <!-- returns a parameter 'bar' -->
			<map:parameter name="foo" value="{foo}"/>

			<map:redirect-to uri="{../foo}{bar}"/>
		</map:act>
	</map:act>
...

an important one to note here is act2's parameter 'foo'; since it's a
parameter to act2 it's not in act2's 'scope', even though the placement of
the <map:parameter> might suggest so. thus the reference is {foo} and not
{../foo}; just think of it as a call from within act1's scope: act2(foo:
{foo})
this is in contrast to the <map:redirect-to>, which is inside act2's scope.
so you have to reference the parent scope for 'foo' and the current scope
for 'bar'.

regarding error flagging there are several possibilities; if you stay in the
same pipeline (no redirects, etc.) you can use request attributes. when
redirecting or similar you could pass an error code or message as request
parameter(s), e.g. <map:redirect-to uri="cocoon:/handle-my-err?fail=act1"/>.
the last resort would be setting a session attribute.

> -----Urspr√ľngliche Nachricht-----
> Von: users-return-63503-m_rolappe=web.de@cocoon.apache.org
> [mailto:users-return-63503-m_rolappe=web.de@cocoon.apache.org]Im Auftrag
> von Anna Bikkina
> Gesendet: Dienstag, 24. Februar 2004 23:38
> An: users@cocoon.apache.org
> Betreff: Re: Actions and parameters in sitemap
>
>
> Can someone please answer the below question.
>
> Also I have nested acts and when the 1st act sends parameters
> will they be
> replaced by the second acts parameters(key in the hashmap are
> different so I
> guess they cannot be replaced). But when I ampassing all these parameters
> (from act1 and act2) to the generator the latest act(act2) parameters are
> being sent the xsp the others (act1 return parameters are not
> being sent).
> Can you someone tell me if I am doing anything wrong.
>
>
> 		<map:act type="startdate" src="security.xsp">
>
>     		   		<map:act type="get-security">
>
> 		    		<map:generate type="serverpages"
> src="securityresult.xsp">
> 		    			<map:parameter
> name="act2msg1" value="{sec_shortname}"/>
> 		    			<map:parameter
> name="act2msg2" value="{sec_piggyback}"/>
> 		    			<map:parameter
> name="act1msg1" value="{startdate}"/>
> 		    			<map:parameter
> name="act1msg2" value="{enddate}"/>
> 		    		</map:generate>
> 		    		<map:transform
> src="context:/historyserver/styles/searchresult.xsl"/>
>     			    <map:serialize/>
>     			</map:act>
>     		</map:act>
>
> I can retrieve act2 messages f in the xsp but act1 messages are null. I
> checked the action is returning parameters.
>
> If act1 fails I want to display an error message which is
> different from the
> message to be displayed when act2 fails. Since both the failure
> are directed
> to the same file is there a way I can find out if act1 or act2 failed and
> depending on that print the error message.
>
>
> Thanks,
> Anna.
>
>
>
> On Monday 23 February 2004 01:01 pm, Anna Bikkina wrote:
> > Hi,
> >
> > I am using multiple action classes to validate my date. I want
> to display
> > error message depending on which action class has failed. I am
> trying to do
> > something like this because that fails. Can someone suggest me
> how can I do
> > this.
> >
> > I am adding a parameter ERROR after every act and trying to use
> it in the
> > xsp and displaying it. I am not able to get it in the security.xsp.ERROR
> > parameter is returning null. Can some suggest a working idea to solve my
> > problem.
> >
> >     <map:match pattern="security.xsp">
> >     	<map:act type="validator">
> >     		<map:parameter name="descriptor"
> > value="/usr/local/jboss/tomcat/webapps/
> > cocoon/historyserver/styles/descriptor.xml"/>
> >
> >     		<map:act type="startdate" src="security.xsp">
> > 			<map:parameter "ERROR"  value="Invalid start date"/>
> >     		    	<map:act type="enddate" src="security.xsp">
> > 				<map:parameter "ERROR"
> value="Invalid end date"/>
> >     		    	<map:act type="validateothers"
> src="security.xsp">
> > 				<map:parameter "ERROR"
> value="Invalid other data"/>
> >     		   		<map:act type="get-security">
> >
> > 		    		<map:generate type="serverpages"
> src="securityresult.xsp"/>
> > 		    		<map:transform src="search.xsl"/>
> > 				     <map:serialize/>
> >     			</map:act>
> >     			</map:act>
> >     			</map:act>
> >     		</map:act>
> >
> >
> >      <map:generate src="security.xsp" type="serverpages"/>
> >
> >
> >      <map:transform src="search.xsl"/>
> >
> >      <map:serialize/>
> >    </map:match>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> > For additional commands, e-mail: users-help@cocoon.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


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


Mime
View raw message