You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kirby Vandivort <kv...@ks.uiuc.edu> on 2003/03/19 21:46:41 UTC

Design philosophy, beans, model to view

I'm in the process of converting a webapp to using struts, am trying to
use "best" practices to make sure that I keep presentation split from
business, and I was wondering what all of you experts do to handle the
data transition from model business logic beans to the presentation.

As I see it, I can make what amounts to a bean for every single page that
is going to be presenting data to the user.  The bean contains the data
and the JSP then displays the values in the bean.

That seems like a real pain to have XXX beans.  It's just a pain to have
to make hundreds of bean classes.  I suspect that I'm missing something
here, but this is what i'm seeing.

Most of the struts documentation that i can find doesn't really address
the simple case of wanting to print data to the user.  Lots of discussion
of making forms in struts, but I'm just wanting to send data back to the
presentation...

The struts-example seems to basically use a single uber bean that contains
all the data and doesn't ever really do much business prep of return
data;  Artimus uses scaffolding to wrap everything in; struts-polls seems
to use Collection and jsp knowledge of class names to get the data out..

So, I guess my question is... is there a consensus of any sort on how
this should be done or, how do you do it, etc?

Thanks,

-- 

Kirby Vandivort                      Theoretical and Computational Biophysics 
Email: kvandivo@ks.uiuc.edu          3051 Beckman Institute
http://www.ks.uiuc.edu/~kvandivo/    University of Illinois
Phone: (217) 244-5711                405 N. Mathews Ave
Fax  : (217) 244-6078                Urbana, IL  61801, USA

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Design philosophy, beans, model to view

Posted by Kirby Vandivort <kv...@ks.uiuc.edu>.
On Wed, Mar 19, 2003 at 04:48:13PM -0500, Rick Reumann wrote:
> On Wed, 19 Mar 2003 14:46:41 -0600
> Kirby Vandivort <kv...@ks.uiuc.edu> wrote:
>  
> > So, I guess my question is... is there a consensus of any sort on how
> > this should be done or, how do you do it, etc?
> 
> Unfortunately, I'm starting to find out more and more that there isn't a
> consensus:) I'm also leaning towards doing things differently now based
> on Vic's basicPortal approach that does not copy formBeans into Data
> Transfer Objects which is what I have been doing (just because I've been
> told that's the way it should it be done for so long). There are some
> things, though, that there seems to be consensus on:
> 
> 1) Your JSPs should go through a controller (Action servlet or a
> subclass of ActionServlet). 

done

> 2) Your persistence layer, that talks to the database or storage, should
> remain separated from any Struts classes. 

and done..

> You might find some of the threads here very helpful
> http://groups.yahoo.com/group/model_struts/

Thanks for the pointer.  I've just joined the group and will take a look
at it.

-- 

Kirby Vandivort                      Theoretical and Computational Biophysics 
Email: kvandivo@ks.uiuc.edu          3051 Beckman Institute
http://www.ks.uiuc.edu/~kvandivo/    University of Illinois
Phone: (217) 244-5711                405 N. Mathews Ave
Fax  : (217) 244-6078                Urbana, IL  61801, USA

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Design philosophy, beans, model to view

Posted by Nathan Steiner <ns...@palmharbor.com>.
I have to agree with this. You want a clear separation of duties across
tiers (at least I do!). We are running in a J2EE environment, so our
approach is:

========
WEB TIER
========
User requests "View Grocery List", which is a link to /view_list.do

ViewGroceryList action class creates a business delegate,
ViewGroceryListDelegate which is a wrapper to an EJB, and requests list -
getList()

Delegate performs JNDI lookup on EJB, and requests list from EJB - getList()

========
EJB TIER
========
EJB creates GroceryListDAO and requests the list - getList()

========
DATA TIER
========
DAO goes out to the database, creates a list of GroceryValueObject's, and
returns them to the EJB

========
BACK TO EJB TIER
========
EJB returns list to delegate

========
BACK TO WEB TIER
========
Delegate returns list to action clas

Action class places list in request and forwards onto tiles definition or
jsp

JSP displays list using <logic:iterate/> or whatever.

We work in parallel on most apps, so I'll do the web tier, and my colleague
will do the EJB/Data tiers. I would look into design patterns, as we use
quite a few in this approach that I didn't go into detail.

HTH!

Nate

-----Original Message-----
From: Rick Reumann [mailto:r@reumann.net]
Sent: Wednesday, March 19, 2003 3:48 PM
To: Struts Users Mailing List
Subject: Re: Design philosophy, beans, model to view


On Wed, 19 Mar 2003 14:46:41 -0600
Kirby Vandivort <kv...@ks.uiuc.edu> wrote:

> So, I guess my question is... is there a consensus of any sort on how
> this should be done or, how do you do it, etc?

Unfortunately, I'm starting to find out more and more that there isn't a
consensus:) I'm also leaning towards doing things differently now based
on Vic's basicPortal approach that does not copy formBeans into Data
Transfer Objects which is what I have been doing (just because I've been
told that's the way it should it be done for so long). There are some
things, though, that there seems to be consensus on:

1) Your JSPs should go through a controller (Action servlet or a
subclass of ActionServlet).

2) Your persistence layer, that talks to the database or storage, should
remain separated from any Struts classes.

You might find some of the threads here very helpful
http://groups.yahoo.com/group/model_struts/


--
Rick Reumann

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Design philosophy, beans, model to view

Posted by Rick Reumann <r...@reumann.net>.
On Wed, 19 Mar 2003 14:46:41 -0600
Kirby Vandivort <kv...@ks.uiuc.edu> wrote:
 
> So, I guess my question is... is there a consensus of any sort on how
> this should be done or, how do you do it, etc?

Unfortunately, I'm starting to find out more and more that there isn't a
consensus:) I'm also leaning towards doing things differently now based
on Vic's basicPortal approach that does not copy formBeans into Data
Transfer Objects which is what I have been doing (just because I've been
told that's the way it should it be done for so long). There are some
things, though, that there seems to be consensus on:

1) Your JSPs should go through a controller (Action servlet or a
subclass of ActionServlet). 

2) Your persistence layer, that talks to the database or storage, should
remain separated from any Struts classes. 

You might find some of the threads here very helpful
http://groups.yahoo.com/group/model_struts/


-- 
Rick Reumann

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org