You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Justin Harvey <bo...@hotmail.com> on 2002/04/29 17:32:54 UTC

FormBeans, Data Beans and Databases (oh my)

Good morning folks (or good afternoon, evening):

I wanted to ask a couple questions and bounce an idea off you guys.

The first is I've been taking my data models and making beans out of them as 
I should ya?  So a user in my "portal" let's call has a UserBean with get() 
set() methods for each of the properties.  But for for registering a user, 
struts requires a FormBean.  So I've repurposed the same data model bean and 
made it a form bean.  Is this good or bad?

Secondly, my beans not only double as data models and formbeans but they 
also have a method which returns a preparedstatement on how to render the 
bean as a SQL insert statement.  Is this good or bad?  What better way to be 
able to translate the bean into the database =).

Are these good ideas or bad ideas?

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: FormBeans, Data Beans and Databases (oh my)

Posted by David Cypers <da...@skynet.be>.
The first is I've been taking my data models and making beans out of them as
I should ya?  So a user in my "portal" let's call has a UserBean with get()
set() methods for each of the properties.  But for for registering a user,
struts requires a FormBean.  So I've repurposed the same data model bean and
made it a form bean.  Is this good or bad?

Do you have 2 identical classes , which are solely different by that they
are implementing another interface or extending an abstract class? Can't you
make a wrapper class from your FormBean which wraps the UserBean? You can do
this by means of 'delegation'. I think that it's better to use delegation
instead of keeping 2 copies of the data model( one in the userbean and one
in the formbean).

D.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>