cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <>
Subject Re: cvs commit: xml-cocoon/webapp/docs/samples/xsp cookie.xsp
Date Wed, 02 May 2001 18:16:56 GMT
At 10:52 PM +0200 30/4/01, giacomo wrote:
>Don't get me wrong. If someone come up with a markup that makes sense
>for action, transormers, whatever I'm +1 for implementing a
>MarkupForActionCompilationAction because I know the model of server
>pages is very convenient :)

OK, lets give it a go.

What can Actions do (please correct me here :)

	1. be passed named parameters
	2. set and get Request and Session properties

This is an entirely fictitious comment book example using the Crudlet TagLib.

In the first file, representing the Action, does all of the Bean creation,
setting Bean Properties automatically from form fields (via their
authenticating "editors"), copying in values from other places and writing
to the Space.

The second file, the XSP, outputs a few properties (as simple values and
blobs of XML) from Beans that are being transparently managed by the
Crudlet TagLib via the user's Session.

The Action

<?xml version="1.0"?>

	<!-- declare the Bean for this request -->
	<crudlet:bean name="comment" class="org.crudlet.CommentBook"

	<!-- assign matching form field names to Bean Properties (validates
internally) -->
	<crudlet:assign bean="comment" autoform="true">

		<!-- copy info from another active Bean -->
		<crudlet:property name="Username">
			<crudlet:value-of bean="User" property="Username"/>

		<!-- copy info extracted from URL by the SiteMap, passed as a parameter
to the Action -->
		<crudlet:property name="ParentId">
			<act:parameter name="PageId"/>

		<!-- fork on success or failure of the Assign (each property validated) -->
			<!-- send success message so SiteMap can react (or is it just XSP or
XSLT that can?) -->
			<!-- added a new tag to the Request TagLib (should this be in the
"act" ns?) -->
			<xsp-request:set-parameter name="assign">true</xsp-request:set-parameter>

			<!-- create the Bean in the Space -->
			<crudlet:event bean="comment" action="create">

				<!-- fork on success or failure of the Create Event (whole bean
validation) -->
					<!-- send success message -->
					<!-- send failure message -->
			<!-- send failure message -->


The XSP Page

<?xml version="1.0"?>
	<!-- Pass the Action results to the XSLT (?) -->
		<assign><xsp-request:get-parameter name="assign"/></assign>
		<create><xsp-request:get-parameter name="create"/></create>

	<!-- info about the comment -->
		<comment-id><crudlet:value-of bean="comment"
		<parent-id><crudlet:value-of bean="comment"
		<author-id><crudlet:value-of bean="comment"
		<prefs><crudlet:copy-of bean="User" property="Preferences.Display"/><prefs>
		<title><crudlet:value-of bean="comment" property="Content.Title"/></title>

	<!-- the comment -->

		<!-- the page introduction -->
			<p>Welcome to blah blah ...</p>

		<!-- the body of the page -->
			<crudlet:copy-of bean="comment" property="Content"/>

		<!-- the page's action -->
		<!-- show an edit button if this comment is from this User, etc. -->
		<!-- xmlns:select is filtered by XSLT -->
		<!-- the "action" chooses the "button" that matches it, or "*" -->
			<xsp:attribute name="select:choose">
				<crudlet:value-of bean="comment" property="Username"/>
			<button action="edit">													<!-- Author -->
				<xsp:attribute name="select:match">
					<crudlet:value-of bean="User" property="Username"/>
			<button action="admin" select:match="Admin"/>		<!-- Admin user -->
			<button action="reply" select:match="*"/>				<!-- anyone else -->

In Cocoon 1, we would have to keep the contents of the Action and the XSP
(above) in the same file, but if we could use XSP Taglibs that need to make
no output inside XML that defines "XSP" Actions and ones that make output
in XSP Pages, we could develop sets of simple generic Actions and XSP
Outputs for our Web Apps that can be mixed and matched by the SiteMap, all
sharing TagLibs.

Does this help?

regards Jeremy


   Jeremy Quinn                                           Karma Divers
                                                       webSpace Design
                                            HyperMedia Research Centre

   <>     		 <>
    <phone:+44.[0].20.7737.6831>        <>

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

View raw message