You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by beyaNet Consultancy <be...@ntlworld.com> on 2004/01/18 15:44:55 UTC

Actions, pipelines, javabeans...

Hi,
I have created an action which returns parameters to a pipeline based 
on a users login details. I want these details to persist for the du 
ration of a user session and wanted to know how to store the values 
passed into the pipeline into a JavaBean instead. At the moment I have 
the parameters coming into my action as so:

1. pipeline

			<map:match pattern="user-details">
				<map:act type="get-detail2">
				    <map:parameter name="user" value="{request-param:user}" />
					<map:parameter name="pass" value="{request-param:pass}" />
					<map:generate type="file" src="content/main.xml" />
					<map:transform src="style/main.xsl">
						<map:transform src="style/main.xsl">
						<map:parameter name="first_name" value="{first_name}" />
						<map:parameter name="last_name" value="{last_name}" />
						<map:parameter name="address1" value="{address1}" />
						<map:parameter name="address2" value="{address2}" />
						<map:parameter name="address3" value="{address3}" />
						<map:parameter name="postcode" value="{postcode}" />
						<map:parameter name="country" value="{country}" />
						<map:parameter name="email" value="{email}" />
						<map:parameter name="home_telephone" value="{home_telephone}" />
						<map:parameter name="mobile_telephone" value="{mobile_telephone}" 
/>
						<map:parameter name="date_joined" value="{data_joined}" />
					</map:transform>
					<map:serialize type="html" />
				</map:act>

and are passed into the pipeline from the Action as so:

2. Action
				map.put("user_id", rs.getString(1));
				map.put("first_name", rs.getString(2));
				map.put("last_name", rs.getString(3));
				map.put("address1", rs.getString(4));
				map.put("address2", rs.getString(5));
				map.put("address3", rs.getString(6));
				map.put("postcode", rs.getString(7));
				map.put("country", rs.getString(8));
				map.put("email", rs.getString(9));
				map.put("home_telephone", rs.getString(10));
				map.put("mobile_telephone", rs.getString(11));
				map.put("date_joined", rs.getString(12));

and then into my xsl page as so

3. xsl
<?xml version="1.0"?>

	<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
		<xsl:param name="user_id"/>
		<xsl:param name="first_name"/>
		<xsl:param name="last_name"/>
		<xsl:param name="address1"/>
		<xsl:param name="address2"/>
		<xsl:param name="address3"/>
		<xsl:param name="postcode"/>
		<xsl:param name="country"/>
		<xsl:param name="email"/>
		<xsl:param name="home_telephone"/>
		<xsl:param name="mobile_telephone"/>
		<xsl:param name="date_joined"/>

Could I call and update the javabean from the within the transform:
<map:transform src="style/main.xsl">
	instatiate javabean
      javabean.user_id = <map:transform src="style/main.xsl">
</map:transform>

Or would it be better to do it from within the Action and then just 
call the call javabean from within the xsl page itself? ultimately I 
want to be able to call the javebean parameters into my xsl or xsp 
pages. What is the best way to go about doing this? Is there any 
example code out there I can have a look at?


Andrew

RE: Actions, pipelines, javabeans...

Posted by Morley Howell <mo...@cogeco.ca>.
Andrew,

The authentication framework that I mentioned in response to your other post
can store any arbitrary XML data associated with the user in the session.
Since it is stored as XML, it becomes really easy to use that information
within the Cocoon pipeline.

For example, I believe you could use an aggregator to aggregate your static
content (main.xml) with the user information XML. Then use XSLT to transform
it however you want, without having to pass all those parameters around all
over the place. This seems much more flexible and extensible to me than the
approach you are taking.

Morley

-----Original Message-----
From: beyaNet Consultancy [mailto:beyanet@ntlworld.com]
Sent: Sunday January 18, 2004 9:45 AM
To: users@cocoon.apache.org
Subject: Actions, pipelines, javabeans...


Hi,
I have created an action which returns parameters to a pipeline based on a
users login details. I want these details to persist for the du ration of a
user session and wanted to know how to store the values passed into the
pipeline into a JavaBean instead. At the moment I have the parameters coming
into my action as so:

1. pipeline

<map:match pattern="user-details">
<map:act type="get-detail2">
<map:parameter name="user" value="{request-param:user}" />
<map:parameter name="pass" value="{request-param:pass}" />
<map:generate type="file" src="content/main.xml" />
<map:transform src="style/main.xsl">
<map:transform src="style/main.xsl">
<map:parameter name="first_name" value="{first_name}" />
<map:parameter name="last_name" value="{last_name}" />
<map:parameter name="address1" value="{address1}" />
<map:parameter name="address2" value="{address2}" />
<map:parameter name="address3" value="{address3}" />
<map:parameter name="postcode" value="{postcode}" />
<map:parameter name="country" value="{country}" />
<map:parameter name="email" value="{email}" />
<map:parameter name="home_telephone" value="{home_telephone}" />
<map:parameter name="mobile_telephone" value="{mobile_telephone}" />
<map:parameter name="date_joined" value="{data_joined}" />
</map:transform>
<map:serialize type="html" />
</map:act>

and are passed into the pipeline from the Action as so:

2. Action
map.put("user_id", rs.getString(1));
map.put("first_name", rs.getString(2));
map.put("last_name", rs.getString(3));
map.put("address1", rs.getString(4));
map.put("address2", rs.getString(5));
map.put("address3", rs.getString(6));
map.put("postcode", rs.getString(7));
map.put("country", rs.getString(8));
map.put("email", rs.getString(9));
map.put("home_telephone", rs.getString(10));
map.put("mobile_telephone", rs.getString(11));
map.put("date_joined", rs.getString(12));

and then into my xsl page as so

3. xsl
<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="user_id"/>
<xsl:param name="first_name"/>
<xsl:param name="last_name"/>
<xsl:param name="address1"/>
<xsl:param name="address2"/>
<xsl:param name="address3"/>
<xsl:param name="postcode"/>
<xsl:param name="country"/>
<xsl:param name="email"/>
<xsl:param name="home_telephone"/>
<xsl:param name="mobile_telephone"/>
<xsl:param name="date_joined"/>

Could I call and update the javabean from the within the transform:
<map:transform src="style/main.xsl">
instatiate javabean
javabean.user_id = <map:transform src="style/main.xsl">
</map:transform>

Or would it be better to do it from within the Action and then just call the
call javabean from within the xsl page itself? ultimately I want to be able
to call the javebean parameters into my xsl or xsp pages. What is the best
way to go about doing this? Is there any example code out there I can have a
look at?


Andrew


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