You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Kasia Lale <ka...@internet.lu> on 2003/11/05 21:34:32 UTC

Woody Bean binding Database

Hi,

I'm hoping somebody can point me in the right direction, please...

I've been looking at Woody and the bean binding sample included in 2.1.(x),
and wondering how i can synchronize the bean with the database, or at least
what's the best way of doing this.

>From reading other posts, I'm thoroughly confused! Best I can figure, the
options are:

* code the connection into the bean itself (or Helper class), using ctx
lookup. [How can Helper class be Composable, or does Helper by-pass Avalon
entirely, perhaps with direct jndi/j2ee datasource lookup?]

* use javascript such as database.js included in the petstore sample to get
a DataSourceComponent/connection and update the bean to/from db in the
(woody) flowscripts

* use Actions (Composable) to lookup a DataSourceComponent and handle db
interraction. How to reference the user's stored (continuation) bean
instance data?

Just for the record, I'm aware of the O/R mapping possibilities using OJB,
and Hibernate, but think I need more basic understanding before potentially
tackling these options. I've also read with interest how betwixt/castor can
be used to output XML representation of a bean for Woody to bind to, but
would still have to ask, how/where can db synchronization be handled?

Thanks for any pointers
James



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Woody Bean binding Database

Posted by Bruno Dumon <br...@outerthought.org>.
On Wed, 2003-11-05 at 21:34, Kasia Lale wrote:
> Hi,
> 
> I'm hoping somebody can point me in the right direction, please...
> 
> I've been looking at Woody and the bean binding sample included in 2.1.(x),
> and wondering how i can synchronize the bean with the database, or at least
> what's the best way of doing this.

Note that if you just want a form to edit something that is in a
database, you don't need a bean and you don't need the binding. The
shortest path is probably using the database.js to get your data from
the database and set the values directly on the form object. And
similary, when saving, just get the values directly from the form and
pass them on to the SQL statement.

> 
> >From reading other posts, I'm thoroughly confused! Best I can figure, the
> options are:
> 
> * code the connection into the bean itself (or Helper class), using ctx
> lookup. [How can Helper class be Composable, or does Helper by-pass Avalon
> entirely, perhaps with direct jndi/j2ee datasource lookup?]

lookup the connection from flowscript, and pass it on to the helper
class, or alternatively make the helper class into an Avalon component,
and declare it in the cocoon.xconf, and then lookup that component from
the flowscript.

> 
> * use javascript such as database.js included in the petstore sample to get
> a DataSourceComponent/connection and update the bean to/from db in the
> (woody) flowscripts
> 
> * use Actions (Composable) to lookup a DataSourceComponent and handle db
> interraction. How to reference the user's stored (continuation) bean
> instance data?
> 
> Just for the record, I'm aware of the O/R mapping possibilities using OJB,
> and Hibernate, but think I need more basic understanding before potentially
> tackling these options. I've also read with interest how betwixt/castor can
> be used to output XML representation of a bean for Woody to bind to, but
> would still have to ask, how/where can db synchronization be handled?
> 
> Thanks for any pointers
> James

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Woody Bean binding Database

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Kasia Lale dijo:
> Hi,
>
> I'm hoping somebody can point me in the right direction, please...
>
> I've been looking at Woody and the bean binding sample included in
> 2.1.(x), and wondering how i can synchronize the bean with the database,
> or at least what's the best way of doing this.

Check the OJB sample inside Cocoon distro.

>
>>>From reading other posts, I'm thoroughly confused! Best I can figure,
>> the
> options are:
>
> * code the connection into the bean itself (or Helper class), using ctx
> lookup. [How can Helper class be Composable, or does Helper by-pass
> Avalon entirely, perhaps with direct jndi/j2ee datasource lookup?]

My current (maybe not the best, but working) solution:

1-Wrap all the DB using OJB with JDO. To make your life easy, use Druid
for that - http://druid.sf.net/

2-Write some Form Handler classes that manage the beans from/to Flow and
Database. In short they interact with the database. I think they can be
called brokers. But I am not sure. I wrote 1 Handler for every Woody form.
(Some forms can interact with more than 1 table at once --- master
details, etc.
3.Flow - is the controller: Create the bean and manage the request at top
level. Inside, the bean we call the "form-database handler" and woody.
4.Woody - View. Just get a bean, interact with the user and return the
bean to the flow.

That is all. I think we have a clean separation of concerns in this way.

> * use javascript such as database.js included in the petstore sample to
> get a DataSourceComponent/connection and update the bean to/from db in
> the (woody) flowscripts
>
> * use Actions (Composable) to lookup a DataSourceComponent and handle db
> interraction. How to reference the user's stored (continuation) bean
> instance data?
>
> Just for the record, I'm aware of the O/R mapping possibilities using
> OJB, and Hibernate, but think I need more basic understanding before
> potentially tackling these options. I've also read with interest how
> betwixt/castor can be used to output XML representation of a bean for
> Woody to bind to, but would still have to ask, how/where can db
> synchronization be handled?

OJB is very nice to do this work.

Cocoon has a built-in support for OJB. More info at:
http://wiki.cocoondev.org/Wiki.jsp?page=OJBBlock

Of course you are welcome in the quest.

Best Regards,

Antonio Gallardo




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org