You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dave Johnson <sn...@nc.rr.com> on 2002/07/11 02:39:51 UTC

An XDoclet approach (was: DynaActionForm Advantages)

Greg.Reddin@alltel.com wrote:

>Something that has always bothered me in Struts is the "disconnect"
>between Form Beans and Model Beans.  How many times do you have a Form
>Bean and a model bean that contain the same data? 
>

In Roller, I solved this problem by using XDoclet.  I use an abstract 
class marked up with both @struts:form and @ejb:data-object tags for 
each of my model objects.  Then XDoclet generates both my model objects 
(data objects, value objects or whatever you want to call them).  The 
form object know how to return data objects, so I don't need to do any 
mapping.

Here is an example of one of those marked up beans:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/roller/roller/src/org/roller/business/beans/BookmarkBean.java?rev=1.1.1.1&content-type=text/vnd.viewcvs-markup

This is not an ideal approach because 1) it assumes that you will have a 
1:1 correspondence between form beans and action beans.  But it works 
well for me.
If I need to have a form with fields that are no part of the corresponding
data object, then I extend the generated form class and add the fields 
that I need.
And 2) the model objects tend to be pretty dumb - but so far this has 
not been a big problem.

You can read more about the Roller architecture here:
http://www.onjava.com/pub/a/onjava/2002/04/17/wblogosj2ee.html

I'd love to hear any feedback about this architecture you might have, 
especially negative feedback - I'd like to know what I can improve.

- Dave




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