cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Ratcliffe" <a...@premasys.com>
Subject RE: Best practice for database access in flow layer
Date Tue, 29 Jun 2004 21:27:12 GMT
Hi Stephan

Thanks for that reference, that was exactly what I needed.  Using
cocoon.createObject()
I was able to instantiate the component directly from the flowscript and
take
advantage of the framework connection pooling and lifecycle methods.

Cheers
Adam

-----Original Message-----
From: Stephan Coboos [mailto:cromosom@gmx.net] 
Sent: Sunday, 27 June 2004 8:05 p.m.
To: dev@cocoon.apache.org
Subject: Re: Best practice for database access in flow layer


Adam Ratcliffe wrote:

>I'm looking for a little direction on the most appropriate way to 
>access a database from the flow layer. My application requires 
>read-only access to the database only so an O/R type approach would 
>probably be overkill.
>
>What I would like to do in the flow layer is something like the 
>following psuedo code. Do a select query against the database using a 
>java component.  Test the returned collection to see if it contains any
>elements and use that test to determine whether redisplay the current
>page or to break out of the
>recursive loop.
>
>Any suggestions?
>
>function searchCategories(locType, class1, class2) {
>    var categories = Search.searchCategories(locType, class1, class2);
>    if(categories != null) {
>       // if search returned categories, search again on expanded 
>categories
>       cocoon.sendPageAndWait("page/showCategories.xml", {"categories" 
>: categories} );
> 
>       // when user request arrives
>       class1 = cocoon.request.getParameter("class1");
>       class2 = cocoon.request.getParameter("class2");
> 
>       // recursively calls itself with 
>       searchCategories(locType, class1, class2);
>    }
>}
>
>
>  
>
Create your own avalon database component. So you can switch the 
persistence layer like you want. Please have a look at the following 
link. (It's in german language but the code should help you. Use class 
"AbstractManagerDB")

http://www.pgmtools.de/board/viewtopic.php?t=35

Regards
Stephan




Mime
View raw message