cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Cameron <>
Subject CRUD,REST,MDA,Cocoon
Date Wed, 16 Jul 2008 03:49:55 GMT


I have designed a relational database schema and have installed it on my db
server and I now want to create a simple CRUD (Create, Read, Update, Delete)
web-application to provide access to the database for users.

I'd like the app to have a clean separation between data and presentation
and be a REST (Representational State Transfer) architecture. This will
allow access to the REST data 'resources' (as xml), and also, for a
presentation layer to be added in order to render each such resource as a UI
in a browser.

I have taken a quick look at the Restlet framework ( but,
having done a little bit of work with Cocoon, I have the idea that I should
be able to create what I want using Cocoon with little or no Java coding.

Having created the database, I can thus generate an xml version of the db
schema using tools such as Apache DDLUtils. So, with my Model (xml schema)
in hand, I would like to generate my application pretty much straight off,
using the Model Driven Architecture (MDA) paradigm. Using standard XSLT
stylesheets I'm thinking I can generate everything I need by translation of
the schema in order to create a Cocoon based application.

These generated documents will probably consist off the following:

1. A sitemap that handles the translation of my RESTful URIs that I need to
embed into my data resource files to create links between resources. I see
the sitemap as handling all the translation from URI to a specific database
table and record or records.
2. Cocoon generator(s) or transformers that do the work of extracting data
from my database and formatting it as xml. Maybe this will be flowscript
using jDBI, or, SQLTransformer.
3. Various CForm files (template and definition), these should be generated
from my schema, maybe there will be some tweeking needed.

To make some points about the above.

I see this aspect as the major potential advantage of Cocoon over other
frameworks for REST, I'd like to configure rather than write code, so,
whilst the sitemap may be large to handle a big database schema the
possibilities that the sitemap can be auto-generated from a db schema and
everything will be in the one place seem attractive for a REST app.

I'd like to avoid having to use an intermediate Java layer between my
generated xml resources and my database repository. JDBC should be a
sufficient interface to the database for this purpose without the need for
O/R mapping. This should be particularly the case in a REST app as I just
want to get a 'representation' of the 'state' of a resource (i.e.database
record) 'transfered' to the client.

For updating records I don't want to (can't?) use record locking so I think
using a record id (primary key) and a timestamp sent to the form will be
necessary. Then, to update a record I'll use SQL like the following - UPDATE
table_name SET .... WHERE primary_key = $id AND last_modified = $timestamp.
If no records are affected then the record has either been deleted or
updated by someone else since the user accessed it and this can be reported
back to the user.

User Interface
I envisage that a standard 'record' page will contain widgets for each field
in the respective table, with each widget having a label and being placed
consecutively down the page. If a table(entity) has child records on other
tables I envisage these records being accessible via a tabbed panel beneath
the record fields. I've not decided how to present such child records, but,
as rows in tables would be standard practice and clicking on a row should
take you to a page displaying that specific record (along with it's children
if any, and so on..).

Data validation before submitting to the database is essential and the
datatype validation in CForms seems very successful, however, the ideal
thing would be do validation on the client, rather than the server as with
CForms, I feel. This kind of functionality is very advanced in the XForms
standard and implementations that I've played with are impressive. I'd like
to experiment with XForms using Cocoon and this seems possible using the
client javascript based implementation 'FormFaces'
( Maybe someone else has gone down this path?

Ideally it would be nice to have query-by-form included in the application
as well, the ability to filter records is essential once the amount of data
becomes significant.

I'm putting these thoughts up in the hope there is someone else who has gone
down these paths and can relate their experiences. Maybe there are some
fatal flaws in what I am proposing :(.

Even better someone who perhaps has some code to share!


Steve Cameron
Data Programmer
eMII Project (

View this message in context:
Sent from the Cocoon - Users mailing list archive at

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

View raw message