For Programmers: Free Programming Magazines  


Home > Archive > Java Beans > October 2004 > am I using my formbean appropriately?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author am I using my formbean appropriately?
Dan Hicks

2004-10-24, 3:56 pm

Hi,

I'm developing a web app and using struts for my view and controller.
I'm new to J2EE and was wondering if it's considered appropriate to
pass my action forms on to my model layer. Form beans in struts I
think are considered part of my view.

On the model side, I have entity beans that contain other beans and
sometimes collections of other beans. My form bean contains ID values
to represent these collections of beans within beans. In other words,
I can't just call beanutils.copyproperties(). I am not using nested
beans for good reason. So I'd like to create a similar functionality
to copy over the properties in my model. My only hesitation in
passing the formbean over is that it may be considered bad form,
because formbeans are considered part of the view, and that makes my
model unusable for other apps (though I'm not expecting to use other
apps). Anybody have any words of wisdom to impart on an MVC novice
such as myself?
Chris Soanes

2004-10-26, 3:56 am

Dan Hicks wrote:
> Hi,
>
> I'm developing a web app and using struts for my view and controller.
> I'm new to J2EE and was wondering if it's considered appropriate to
> pass my action forms on to my model layer. Form beans in struts I
> think are considered part of my view.


You are correct, beans that extend ActionForm are part of the view. The
model should have no knowledge of these, so it's not (IMO) a good idea
to pass form beans to the model. Your saving grace in struts is going to
be the action classes, as you can use these to take the properties of
your form beans and pass massage them into the form your model needs.
This is my understanding of the 'C' in MVC pattern - you control the
interaction between the model and the view. I stand to be corrected,
however, as I'm an MVC n00b meself.

Tiff
--
Chris M Soanes: Sailor, Windsurfer, Cyclist, Biker, Snowboarder,
Swimmer, Dog Owner, and above all, G.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com