struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vilya Harvey <vilya.har...@digitalsteps.com>
Subject Re: Struts + Hibernate: A few newbie questions about how to get this right?
Date Thu, 24 Jul 2003 15:05:55 GMT
Thorbjørn Ravn Andersen wrote:
> * Can I use a persistant bean as my FormBean (or would that be asking 
> for inconsistencies), or should I work with a DynaBean and then copy the 
> result to the persistant bean in the end?  I will probably need some 
> validation.

You could, I believe, but AFAIK it's not recommended. The Struts form beans 
are really part of the view layer and should be kept separate from the 
business and persistence layers where possible. A better approach is to use 
a DynaBean for collecting the form data and have the actions copy it into 
the appropriate model class.

> * If not, is there an easy way to populate such a DynaBean from my 
> persistant bean and vice versa?  I would rather not have to write a lot 
> of setXX( getXX()) statements.

Have a look at the commons-beanutils package that comes with Struts. In 
particular, you'll probably find BeanUtils.copyProperties() quite helpful.

Hope that helps,
Vil.
-- 
Vilya Harvey
vilya.harvey@digitalsteps.com                 / digital steps /
(W) +44 (0)1483 469 480
(M) +44 (0)7816 678 457                 http://www.digitalsteps.com/

--Disclaimer--

This e-mail and any attachments may be confidential and/or legally
privileged. If you have received this email and you are not a named
addressee, please inform the sender at Digital Steps Ltd by phone on
+44 (0)1483 469 480 or by reply email and then delete the email from
your system. If you are not a named addressee you must not use,
disclose, distribute, copy, print or rely on this email. Although
Digital Steps Ltd routinely screens for viruses, addressees should
check this email and any attachments for viruses. Digital Steps Ltd
makes no representation or warranty as to the absence of viruses in this
email or any attachments.

Mime
View raw message