Bertrand Delacretaz wrote:

Le 7 oct. 05, à 15:31, Upayavira a écrit :

...I believe there are some new ways being played with for database access in cforms. Using jdbi (I believe). Hopefully we'll hear more soon...


I believe I've seen it, actually...so yes, we hope to hear more soon ;-)


Yup. This is something I'm working on for my current project and which should land this week in the SVN.

Basically, JDBI allows to access JDBC using List and Map rather than ResultSet, and I added List and Map implementations that wrap a CForms repeater and container, respectively.

This allows to write things like:

var form = new Form("myform.xml");
// Get a Map view on the form
var formMap = form.asMap();
// Load a Map representing a customer from the database
var customer = jdbi.query("select * from customer where id = :id", { id: cocoon.request.getParameter("id") });
// Fill the form
formMap.putAll(customer);

form.showForm("viewform");
if (form.isValid) {
   // Update customer
jdbi.update("update customer set name = :name, email = :email where id = :id", formMap);
}

Et voilà: for simple CRUD needs, direct mapping from database table to form without complex O/R mapping tools.

Sylvain

--
Sylvain Wallez                        Anyware Technologies
http://people.apache.org/~sylvain     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to