RE: FormBeans: A question of Style

2004-02-27 Thread Max Cooper
On Thu, 2004-02-26 at 23:01, Pradeep, PK wrote:
 I think whatever you do you can't make JSP and Action Class independent.
 Where are you populating ActionForm Object from the results from service
 layer? In Action class only right? Which you know very well for which
 JSP page it will be applicable.

True, but having one well-defined interface between the two (an
ActionForm) is preferable to having a handful of poorly-defined
interfaces between them (an ActionForm + stuffing a bunch of stuff into
the request).

 
 Also is it easy to populate all what you need in ActionForm? How one can
 populate resultset in action form which will automatically get populated
 in html table..

Yes, call myActionForm.setResults(results) instead of
request.setAttribute(results, results). This may seem like a minor
point (and it is admittedly a simple example), but maintaining complex
pages with a lot of structured data behind them gets difficult when you
have to pull a bunch of stuff out of the request with no structure
defined between the items you are pulling. Using the ActionForm as the
root of your data structure is a simple rule to follow that 'scales up'
(with data structure complexity) much better than request-stuffing.

-Max



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: FormBeans: A question of Style

2004-02-27 Thread Michael McGrady
This is just wrong.  This is done everyday.  They are not in the least 
dependent.

At 11:01 PM 2/26/2004, you wrote:
I think whatever you do you can't make JSP and Action Class independent.
Where are you populating ActionForm Object from the results from service
layer? In Action class only right? Which you know very well for which
JSP page it will be applicable.
Also is it easy to populate all what you need in ActionForm? How one can
populate resultset in action form which will automatically get populated
in html table..


-Original Message-
From: Max Cooper [mailto:[EMAIL PROTECTED]
Sent: Friday, February 27, 2004 11:41 AM
To: Struts Users Mailing List
Subject: Re: FormBeans: A question of Style
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, [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: FormBeans: A question of Style

2004-02-27 Thread Paul, R. Chip
Agreed.  Consider these scenarios:

A single form used with multiple actions (think view/edit/new)
A tile that conforms to some interface implemented by multiple forms, that
is used on different pages
An action that manipulates data and forwards to multiple views (WML vs XML
vs HTML, or maybe Table vs Graph)

Independence is very important for reusability and maintainability.

-Original Message-
From: Michael McGrady [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 27, 2004 4:53 PM
To: Struts Users Mailing List
Subject: RE: FormBeans: A question of Style


This is just wrong.  This is done everyday.  They are not in the least 
dependent.

At 11:01 PM 2/26/2004, you wrote:
I think whatever you do you can't make JSP and Action Class 
independent. Where are you populating ActionForm Object from the 
results from service layer? In Action class only right? Which you know 
very well for which JSP page it will be applicable.

Also is it easy to populate all what you need in ActionForm? How one 
can populate resultset in action form which will automatically get 
populated in html table..



-Original Message-
From: Max Cooper [mailto:[EMAIL PROTECTED]
Sent: Friday, February 27, 2004 11:41 AM
To: Struts Users Mailing List
Subject: Re: FormBeans: A question of Style

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, [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: FormBeans: A question of Style

2004-02-26 Thread Max Cooper
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, [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: FormBeans: A question of Style

2004-02-26 Thread Niall Pemberton
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: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: FormBeans: A question of Style

2004-02-26 Thread Andrew Hill
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:[EMAIL PROTECTED]
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: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: FormBeans: A question of Style

2004-02-26 Thread cnd
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:[EMAIL PROTECTED]
 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: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 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: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: FormBeans: A question of Style

2004-02-26 Thread Pradeep, PK
I think whatever you do you can't make JSP and Action Class independent.
Where are you populating ActionForm Object from the results from service
layer? In Action class only right? Which you know very well for which
JSP page it will be applicable.

Also is it easy to populate all what you need in ActionForm? How one can
populate resultset in action form which will automatically get populated
in html table..



-Original Message-
From: Max Cooper [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 27, 2004 11:41 AM
To: Struts Users Mailing List
Subject: Re: FormBeans: A question of Style

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, [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: FormBeans: A question of Style

2004-02-26 Thread Andrew Hill
snip
I think whatever you do you can't make JSP and Action Class independent.
Where are you populating ActionForm Object from the results from service
layer? In Action class only right? Which you know very well for which
JSP page it will be applicable.
/snip

True

snip
How one can
populate resultset in action form which will automatically get populated
in html table..
/snip

Shouldnt be passing a resultset to the JSP.
Better to extract the info you need from it so you can free up the
connection before forwarding to the JSP. Take a look at:
http://jakarta.apache.org/commons/beanutils/api/

-Original Message-
From: Pradeep, PK [mailto:[EMAIL PROTECTED]
Sent: Friday, 27 February 2004 15:02
To: Struts Users Mailing List
Subject: RE: FormBeans: A question of Style


I think whatever you do you can't make JSP and Action Class independent.
Where are you populating ActionForm Object from the results from service
layer? In Action class only right? Which you know very well for which
JSP page it will be applicable.

Also is it easy to populate all what you need in ActionForm? How one can
populate resultset in action form which will automatically get populated
in html table..



-Original Message-
From: Max Cooper [mailto:[EMAIL PROTECTED]
Sent: Friday, February 27, 2004 11:41 AM
To: Struts Users Mailing List
Subject: Re: FormBeans: A question of Style

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, [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]