You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sc...@circuitcity.com on 2004/02/27 02:57:35 UTC

FormBeans: A question of Style

We have 2 camps of thought on the subject of the appropriate use of Struts
form beans.  Here are the thoughts:

Camp 1:  Form beans are controller components and should be used only to
transport user input data between JSP forms (or across JSP forms) and
Action classes.

Camp 2: Form beans should be use for what "Camp 1" thinks, plus they should
also contain all the data a JSP uses to render a page (i.e. All the model
data is inserted into the form bean as well as the form data.)

Any thoughts?

Scott



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


RE: FormBeans: A question of Style

Posted by cn...@rayc.brevsville.com.au.
I agree Camp 3. All the text I have read on MVC advise that the business
logic should be performed by calling service modules out of the action
class.

On Fri, 27 Feb 2004, Andrew Hill wrote:

> Im with camp 3 then I guess.
>
> Way I see it , forms are view components, there to provide an object for
> both action and JSP to be able to access the state of the screen. (Fields
> values and other bits of information that are needed to recreate the html,
> and a place to hold the state of the view (ie: submitted field values) on
> the server side for the controller (action) to read from)
>
> Maybe we should raise an issue in bugzilla against the userguide? Forms have
> no business transfering stuff from view to model. The model should never
> have to see an actionForm and should be blissfuly unaware of their very
> existence. Thats the job of an action to do, taking data from the form, and
> providing it to the model and vice versa (preferably with some kind of
> helper classes and perhaps also non-form DTOs involved)
>
> -----Original Message-----
> From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
> Sent: Friday, 27 February 2004 12:12
> To: Struts Users Mailing List
> Subject: Re: FormBeans: A question of Style
>
>
> Dam - I was in Camp 3: Form beans are View components...but looking in the
> user guide...
>
> "Note: While ActionForm beans often have properties that correspond to
> properties in your Model beans, the form beans themselves should be
> considered a Controller component. As such, they are able to transfer data
> between the Model and View layers."
>
> Niall
>
> ----- Original Message -----
> From: <Sc...@circuitcity.com>
> To: <st...@jakarta.apache.org>
> Sent: Friday, February 27, 2004 1:57 AM
> Subject: FormBeans: A question of Style
>
>
> >
> > We have 2 camps of thought on the subject of the appropriate use of Struts
> > form beans.  Here are the thoughts:
> >
> > Camp 1:  Form beans are controller components and should be used only to
> > transport user input data between JSP forms (or across JSP forms) and
> > Action classes.
> >
> > Camp 2: Form beans should be use for what "Camp 1" thinks, plus they
> should
> > also contain all the data a JSP uses to render a page (i.e. All the model
> > data is inserted into the form bean as well as the form data.)
> >
> > Any thoughts?
> >
> > Scott
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>
>
> ---------------------------------------------------------------------
> 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: FormBeans: A question of Style

Posted by Andrew Hill <an...@gridnode.com>.
Im with camp 3 then I guess.

Way I see it , forms are view components, there to provide an object for
both action and JSP to be able to access the state of the screen. (Fields
values and other bits of information that are needed to recreate the html,
and a place to hold the state of the view (ie: submitted field values) on
the server side for the controller (action) to read from)

Maybe we should raise an issue in bugzilla against the userguide? Forms have
no business transfering stuff from view to model. The model should never
have to see an actionForm and should be blissfuly unaware of their very
existence. Thats the job of an action to do, taking data from the form, and
providing it to the model and vice versa (preferably with some kind of
helper classes and perhaps also non-form DTOs involved)

-----Original Message-----
From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
Sent: Friday, 27 February 2004 12:12
To: Struts Users Mailing List
Subject: Re: FormBeans: A question of Style


Dam - I was in Camp 3: Form beans are View components...but looking in the
user guide...

"Note: While ActionForm beans often have properties that correspond to
properties in your Model beans, the form beans themselves should be
considered a Controller component. As such, they are able to transfer data
between the Model and View layers."

Niall

----- Original Message -----
From: <Sc...@circuitcity.com>
To: <st...@jakarta.apache.org>
Sent: Friday, February 27, 2004 1:57 AM
Subject: FormBeans: A question of Style


>
> We have 2 camps of thought on the subject of the appropriate use of Struts
> form beans.  Here are the thoughts:
>
> Camp 1:  Form beans are controller components and should be used only to
> transport user input data between JSP forms (or across JSP forms) and
> Action classes.
>
> Camp 2: Form beans should be use for what "Camp 1" thinks, plus they
should
> also contain all the data a JSP uses to render a page (i.e. All the model
> data is inserted into the form bean as well as the form data.)
>
> Any thoughts?
>
> Scott
>
>
>
> ---------------------------------------------------------------------
> 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



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


Re: FormBeans: A question of Style

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
Dam - I was in Camp 3: Form beans are View components...but looking in the
user guide...

"Note: While ActionForm beans often have properties that correspond to
properties in your Model beans, the form beans themselves should be
considered a Controller component. As such, they are able to transfer data
between the Model and View layers."

Niall

----- Original Message ----- 
From: <Sc...@circuitcity.com>
To: <st...@jakarta.apache.org>
Sent: Friday, February 27, 2004 1:57 AM
Subject: FormBeans: A question of Style


>
> We have 2 camps of thought on the subject of the appropriate use of Struts
> form beans.  Here are the thoughts:
>
> Camp 1:  Form beans are controller components and should be used only to
> transport user input data between JSP forms (or across JSP forms) and
> Action classes.
>
> Camp 2: Form beans should be use for what "Camp 1" thinks, plus they
should
> also contain all the data a JSP uses to render a page (i.e. All the model
> data is inserted into the form bean as well as the form data.)
>
> Any thoughts?
>
> Scott
>
>
>
> ---------------------------------------------------------------------
> 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: FormBeans: A question of Style

Posted by Max Cooper <ma...@maxcooper.com>.
I consider the ActionForms to be part of the view primarily. They should
both collect submitted data and provide the JSP (or other view
components) with most or all the data they need to render the page (camp
2). I say 'most' only because sometimes custom tags can be useful for
getting data for list boxes, etc. All the data that the Action collects,
however, should be carried to the JSP in the ActionForm.

The alternatives for carrying data from Actions to JSPs for the camp 1
gang are not attractive, in my opinion. Having an Action put a bunch of
stuff into the request or session scope creates a lot of coupling
between the Action and JSP. The Action must know where to put it and the
JSP must know where to find it with that scenario. I prefer to keep the
Actions and JSPs loosely coupled by having them both depend on the
ActionForm, rather than depending on each other. The Action populates
the ActionForm, and the JSP renders it.

For complex pages, the ActionForm can be the root of an object graph
that contains all the data you need to render the page. Stashing
additional info all over the session and request is "sloppy" by
comparison, in my opinion. I think the "ActionForm is the root of all
view data" approach promotes more concentrated thought about the
structure of the data, which is a good thing. It provides a more
concrete interface between the controller (Action) and view (JSP)
components. Maintaining JSPs that get their data from one place is much
easier than maintaining JSPs that have to collect, organize, and display
data from multiple sources. JSPs that pull data from the ActionForm,
stuff stashed in the session, and/or stuff stashed in the request are
harder to maintain. Where do I find it? How does it all relate? Yuk!

-Max

On Thu, 2004-02-26 at 17:57, Scott_Schenkein@circuitcity.com wrote:
> We have 2 camps of thought on the subject of the appropriate use of Struts
> form beans.  Here are the thoughts:
> 
> Camp 1:  Form beans are controller components and should be used only to
> transport user input data between JSP forms (or across JSP forms) and
> Action classes.
> 
> Camp 2: Form beans should be use for what "Camp 1" thinks, plus they should
> also contain all the data a JSP uses to render a page (i.e. All the model
> data is inserted into the form bean as well as the form data.)
> 
> Any thoughts?
> 
> Scott
> 
> 
> 
> ---------------------------------------------------------------------
> 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