Return-Path: Delivered-To: apmail-cocoon-docs-archive@www.apache.org Received: (qmail 26955 invoked from network); 5 Jul 2004 12:07:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 5 Jul 2004 12:07:00 -0000 Received: (qmail 53595 invoked by uid 500); 5 Jul 2004 12:07:00 -0000 Delivered-To: apmail-cocoon-docs-archive@cocoon.apache.org Received: (qmail 53544 invoked by uid 500); 5 Jul 2004 12:06:58 -0000 Mailing-List: contact docs-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: docs@cocoon.apache.org Delivered-To: mailing list docs@cocoon.apache.org Received: (qmail 53522 invoked by uid 99); 5 Jul 2004 12:06:58 -0000 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Mon, 05 Jul 2004 05:06:56 -0700 Received: (qmail 26900 invoked from network); 5 Jul 2004 12:06:54 -0000 Received: from localhost.hyperreal.org (HELO minotaur.apache.org) (127.0.0.1) by localhost.hyperreal.org with SMTP; 5 Jul 2004 12:06:54 -0000 Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: docs@cocoon.apache.org To: docs@cocoon.apache.org Subject: =?iso-8859-1?q?=5BCocoon_Wiki=5D_Updated=3A__GroovyWithSQLDatabaseAccess?= Date: Mon, 05 Jul 2004 12:06:54 -0000 Message-ID: <20040705120654.26888.65032@minotaur.apache.org> X-Spam-Rating: localhost.hyperreal.org 1.6.2 0/1000/N X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Date: 2004-07-05T05:06:54 Editor: AndrewCates Wiki: Cocoon Wiki Page: GroovyWithSQLDatabaseAccess URL: http://wiki.apache.org/cocoon/GroovyWithSQLDatabaseAccess no comment Change Log: ---------------------------------------------------------------------------= --- @@ -8,99 +8,99 @@ = '''With XSP, to display a football list players from my database i do this= ''' ---- -{{{ - - foot - - SELECT * FROM m_player - - - - - - - - - - - - - - - - - - +{{{ + + foot + + SELECT * FROM m_player + + + + + + + + + + + + + + + + + + }}} ---- = '''Now with Groovy i just have to do this''' = ---- -{{{ -import groovy.sql.Sql -// Generate XML using the (way cool) GroovyMarkup syntax -import groovy.xml.SAXBuilder - -sql =3D Sql.newInstance('jdbc:postgresql://localhost:5432/foot, "footlogin= ","footpass","org.postgresql.Driver") - -// Create a Groovy Builder which writes directly to the Cocoon pipeline -contentHandler =3D bsf.lookupBean("contentHandler") -xml =3D new SAXBuilder(contentHandler) - -contentHandler.startDocument() -xml.root() { - - sql.eachRow('select * from m_player') { plr | - xml.player() { - id_player(plr.id_player); - player_name(plr.player_name); - player_url_name(plr.player_url_name); - player_birth(plr.player_birth); - player_town(plr.player_town); - player_size(plr.player_size); - player_weight(plr.player_weight); - player_start(plr.player_start); - player_photo(plr.player_photo); - player_position(plr.player_position); - id_club(plr.id_club); - } - } - -} - -sql.close() -contentHandler.endDocument() -// thats it. +{{{ +import groovy.sql.Sql +// Generate XML using the (way cool) GroovyMarkup syntax +import groovy.xml.SAXBuilder + +sql =3D Sql.newInstance('jdbc:postgresql://localhost:5432/foot, "footlogin= ","footpass","org.postgresql.Driver") + +// Create a Groovy Builder which writes directly to the Cocoon pipeline +contentHandler =3D bsf.lookupBean("contentHandler") +xml =3D new SAXBuilder(contentHandler) + +contentHandler.startDocument() +xml.root() { + + sql.eachRow('select * from m_player') { plr | + xml.player() { + id_player(plr.id_player); + player_name(plr.player_name); + player_url_name(plr.player_url_name); + player_birth(plr.player_birth); + player_town(plr.player_town); + player_size(plr.player_size); + player_weight(plr.player_weight); + player_start(plr.player_start); + player_photo(plr.player_photo); + player_position(plr.player_position); + id_club(plr.id_club); + } + } + +} + +sql.close() +contentHandler.endDocument() +// thats it. }}} ---- = =3D=3D=3D To use your groovy script, as describe in the sample BSF block d= o the following in your sitemap : =3D=3D=3D = The generator : = -{{{ - - - - - groovy - gy - - - - +{{{ + + + + + groovy + gy + + + + }}} = The matcher = -{{{ - - - - - - +{{{ + + + + + + }}} -I hope this could help. +I hope this helps. = -- [http://wiki.cocoondev.org/Wiki.jsp?page=3DOlivierDemah olivier demah] = -- = =20