Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 36455 invoked from network); 17 Feb 2004 10:31:30 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 17 Feb 2004 10:31:30 -0000 Received: (qmail 21117 invoked by uid 500); 17 Feb 2004 10:30:55 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 21109 invoked by uid 500); 17 Feb 2004 10:30:55 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: users@cocoon.apache.org Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 21093 invoked from network); 17 Feb 2004 10:30:54 -0000 Received: from unknown (HELO paris.dvs1.informatik.tu-darmstadt.de) (130.83.27.43) by daedalus.apache.org with SMTP; 17 Feb 2004 10:30:54 -0000 Received: from informatik.tu-darmstadt.de (border2.basf-ag.de [141.6.8.36]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by paris.dvs1.informatik.tu-darmstadt.de (Postfix) with ESMTP id B279AFE51 for ; Tue, 17 Feb 2004 11:31:07 +0100 (MET) Message-ID: <4031ED6A.2060303@informatik.tu-darmstadt.de> Date: Tue, 17 Feb 2004 11:31:06 +0100 From: Christian Haul User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: users@cocoon.apache.org Subject: Re: Best practice for "database" manipulation? References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N H.vanderLinden@MI.unimaas.nl wrote: >>Other than that, my advice is to put your database access into a java >>class (better: Avalon components) and access it from flow. If >>you cannot >>or don't want to use flow, use actions to access it. > > > Hmm. Could you give a more detailed example of how this would look like with > either flow or actions? I do have some Java classes now that do the actual > database connection, which I now call from my XSP page. So it would be very > helpful if you could write down a (set of) sitemap pattern(s) with a round > trip (i.e. put query into "DatabaseConnection", put result through Woody on > screen, put result back into "DatabaseConnection"). Well, I can't really help on the Woody part. For an action, tha pattern is match pattern="use case 1" act type="guard that conditions are satisfied" act type="do something with connection" call resource="display results handed down from action through eg. request attributes" /act call resource="display error message for connection" /act call resource="display error message for conditions" /match For flow, the pattern is: function useCase1() { userDate = new UserData(); do { send_start_page_and_optional_condition_errors(userData); userData = read_parameters_back(); done = check_conditions(userData); } while (!done); if (do_something_with_connection(userData)) { send_query_result_page(); } else { send_connection_error_page(); } } If the logic is contained in avalon components, you'd need to obtain them first (AFAIR cocoon.newInstance(MYCOMPONENT.ROLE)) and release them afterwards. Remember to release components before creating a continuation, though. > I don't like the idea of handling _everything_ in flow (like the petstore > example), which would make me look in two places (flow and sitemap) to find > out what's going on. I do use flow with Woody, but then I prefer to use and > reuse generic functions where all the variables (which > template/binding/definition and where to redirect to) are passed in as > parameters from the sitemap. I guess that I prefer flow to actions because > it's easier to debug and modify. The key is to use flow _only_ to call your business logic (which is in avalon components) in correct order and react to exceptions (error conditions, user faults). Personally, I would try to avoid redirects where possible and hide a complete use case (or user story) under a single URL. Chris. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org