cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephan Coboos <cromo...@gmx.net>
Subject Re: Best practice for database access in flow layer
Date Sun, 27 Jun 2004 08:04:31 GMT
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