On 16 Feb 2004, at 15:16, Kelly wrote:

I am also looking for a snippet of sample code
without the weight of the Petstore example to open a connection to cocoon.xconfig-defined pool.

This is ancient, untested against current Cocoon HEAD, and code I wrote without people keeping my hands off the keyboard, so caveat emptor.


cocoon.load("resource://org/apache/cocoon/woody/flow/javascript/ woody.js");
cocoon.load("resource://org/apache/cocoon/components/flow/javascript/ Database.js");


function form(form) {

[...]

var conn = getConnection("gt2003");

try {

if (checkRecordInDatabase(model.email, conn) == true) {

           var pipeline = "registration/" + eventid + "/duplicate";
           cocoon.sendPage(pipeline, {"email": model.email});

        }
        else {

[...]

addRecord(registration, conn);

[...]

}

} finally {

conn.close();

    }
}

[...]

function getConnection(id) {
  return Database.getConnection(id)
}

function addRecord(registration, conn) {

var updatestmt = "INSERT INTO registration " +
"(fname, lname, company, address, city, zip, country, tel, fax, email, eventid, hash, event6th, event7th) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";


conn.update(updatestmt, registration.asInsertValues());

}

</Steven>
--
Steven Noels                            http://outerthought.org/
Outerthought - Open Source Java & XML            An Orixo Member
Read my weblog at            http://blogs.cocoondev.org/stevenn/
stevenn at outerthought.org                stevenn at apache.org



Reply via email to