-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Struts ActionForm as persistent object
PostPosted: Sun Mar 28, 2004 12:43 pm 
Beginner
Beginner

Joined: Sun Mar 28, 2004 9:01 am
Posts: 21
Hi,

I'm using Struts as web application framework. When using Forms within Struts I have all data within those struts ActionForm objects accessed by getter and setter methods. Within my framework those ActionForm objects have methods that can load data from the database using jdbc.

When changing the persistence layer to hibernate I thought it would be best to make those ActionForm objects persistent.

When looking for examples and best practised using Hibernate with Struts I found only examples that use POJO that will be persisted and ActionForm for presentation. The data are transfered via the Bean method BeanUtils.copyProperties(POJO, ActionForm).

My question is why not persist the ActionForm objects themselves? Is there a notable drawback that I haven't seen yet?

Thanks!
Rene


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 28, 2004 2:34 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Hibernate is more usefull if you use "domain model", it is very trivial to integrate with struts:

myForm.getDomainObject();

BeanUtils supports it too:

<html:text property="domainObject.someProperty" />

It must be a better way, form objects are not "model" in struts MVC terminology.


Top
 Profile  
 
 Post subject: Re: Struts ActionForm as persistent object
PostPosted: Sun Mar 28, 2004 9:08 pm 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
FelderR wrote:
My question is why not persist the ActionForm objects themselves? Is there a notable drawback that I haven't seen yet?


Rene,

I am fairly new to Hibernate but I have a pretty decent background in Struts. While I cannot give you a perfect answer from the Hibernate perspective as to why the ActionForms cannot be used for persistence, I believe that from a Struts point of view it could be deemed as "improper" use of ActionForms. Reason being that the purpose of the ActionForms is solely to collect information from the user and pass it on to the Model to be used with the Business Layer for the application. The same argument could be made for not using ActionForms as the Model itself and passing it to any data persistence layer, be it JDBC or Hibernate. From an MVC architectural point of view I would think that mixing the ActionForms with the Model could possibly cause Design issues once the application gets big.

Personally, I prefer having DynaValidatorForms defined in the struts-config.xml and populate my individual beans with PropertyUtils.setProperty() and use the bean in my Business Layer for processing.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.