You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Mattos, John" <jm...@Indemand.com> on 2002/02/13 19:08:44 UTC

Passing Action Errors from one perform() method to another perfor m() method - Expert help?

Hi all.

I'm trying to do the following.

In an Action.perform() method, I'm adding an ActionErrors object to the
request as follows

// Snippet from an Action.perform() method
ActionErrors errors = new ActionErrors ();
errors.add("Processed", new ActionError("Processing Done"));
saveErrors(request, errors);
return new ActionForward("/suspends.do");
// End of first perform() snippet

Notice that I'm forwarding to a ".do", which means I'm in another perform()
method

in the SECOND perform() method, I want to do some preprocessing (get stuff
from a database)
then forward to a JSP, and INLCUDE the actionErrors object from the first
perform() method.
Here's how I'm doing that now....

// snipped from second perform() method, mapped to suspends.do
ActionErrors errors = new ActionErrors();
errors= (ActionErrors)request.getAttribute("Processed");		
saveErrors (request, errors);
	    
return new ActionForward("/invoicing/suspendsSummary.jsp");
// End of second perform() snippet

am I going about this in the wrong way? Is this even possible?

basically, I want to pass a message back to the jsp that is really a status
message (as in.. I'm done processing)

thoughts?
John Mattos
Sr. Developer and Architect
iNDEMAND
345 Hudson St. 16th Floor
New York, New York
10014

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


Re: Passing Action Errors from one perform() method to another perfor m() method - Expert help?

Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "John" == John Mattos <Mattos> writes:

    John> Hi all.
    John> I'm trying to do the following.

    John> In an Action.perform() method, I'm adding an ActionErrors object to the
    John> request as follows

    John> // Snippet from an Action.perform() method
    John> ActionErrors errors = new ActionErrors ();
    John> errors.add("Processed", new ActionError("Processing Done"));
    John> saveErrors(request, errors);
    John> return new ActionForward("/suspends.do");
    John> // End of first perform() snippet

    John> Notice that I'm forwarding to a ".do", which means I'm in another perform()
    John> method

    John> in the SECOND perform() method, I want to do some preprocessing (get stuff
    John> from a database)
    John> then forward to a JSP, and INLCUDE the actionErrors object from the first
    John> perform() method.
    John> Here's how I'm doing that now....

    John> // snipped from second perform() method, mapped to suspends.do
    John> ActionErrors errors = new ActionErrors();
    John> errors= (ActionErrors)request.getAttribute("Processed");		
    John> saveErrors (request, errors);
	    
    John> return new ActionForward("/invoicing/suspendsSummary.jsp");
    John> // End of second perform() snippet

    John> am I going about this in the wrong way? Is this even possible?

    John> basically, I want to pass a message back to the jsp that is really a status
    John> message (as in.. I'm done processing)

You may be showing an inappropriate example, but I would say that you're trying
to store information that is not an error.  I would just create a collection as
a session attribute and store this information.  You can display the records in
that collection in each JSP in the workflow.

-- 
===================================================================
David M. Karr          ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net


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


Re: Passing Action Errors from one perform() method to another perform() method - Expert help?

Posted by Ted Husted <hu...@apache.org>.
As long as you are not redirecting, the ActionErrors object is going to
be there when you get to the 2nd action, and ultimately the presentation
page. 

What I would do is put a method on a base action that can check for an
Action.ERRORS object in the request, and either use that or create a new
one. That way subsequent actions could add to it, without overwriting
the first one. Or, override SaveErrors to look before it leaps, and
append to the Action.ERRORS object if it is already there. 

Although there is a messages object in the nightly build, many of my
applications use the ActionErrors for confirmation messages too.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/



"Mattos, John" wrote:
> 
> Hi all.
> 
> I'm trying to do the following.
> 
> In an Action.perform() method, I'm adding an ActionErrors object to the
> request as follows
> 
> // Snippet from an Action.perform() method
> ActionErrors errors = new ActionErrors ();
> errors.add("Processed", new ActionError("Processing Done"));
> saveErrors(request, errors);
> return new ActionForward("/suspends.do");
> // End of first perform() snippet
> 
> Notice that I'm forwarding to a ".do", which means I'm in another perform()
> method
> 
> in the SECOND perform() method, I want to do some preprocessing (get stuff
> from a database)
> then forward to a JSP, and INLCUDE the actionErrors object from the first
> perform() method.
> Here's how I'm doing that now....
> 
> // snipped from second perform() method, mapped to suspends.do
> ActionErrors errors = new ActionErrors();
> errors= (ActionErrors)request.getAttribute("Processed");
> saveErrors (request, errors);
> 
> return new ActionForward("/invoicing/suspendsSummary.jsp");
> // End of second perform() snippet
> 
> am I going about this in the wrong way? Is this even possible?
> 
> basically, I want to pass a message back to the jsp that is really a status
> message (as in.. I'm done processing)
> 
> thoughts?
> John Mattos
> Sr. Developer and Architect
> iNDEMAND
> 345 Hudson St. 16th Floor
> New York, New York
> 10014
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

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


BIG DUMMY: SQL in Logic Bean or Action class

Posted by Phase Communcations <ma...@phase.ws>.
SORRY I FORGOT TO TO CHANGE THE RECIPIENT.

-----Original Message-----
From: Phase Communcations [mailto:mail@phase.ws]
Sent: Thursday, February 14, 2002 9:03 AM
To: Struts Users Mailing List
Subject: RE: SQL in Logic Bean or Action class


Hey sean,

The following is some dialog I had with a couple of guys on the message
board about sql placement. I thought you might find it interesting.
Ultimately, just read Ted Husted.

Also, I have some thoughts I would like to pass by you when you have a few
moments. I have to make some changes to my content management. I have run
into a minor snag.

Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws


-----Original Message-----
From: Ted Husted [mailto:husted@apache.org]
Sent: Wednesday, February 13, 2002 8:55 PM
To: Struts Users Mailing List
Subject: Re: SQL in Logic Bean or Action class


It sounds fine to me.

The important thing is to follow the layers pattern

[ view ] | [ controller ] | [ model ]

The view can talk to the controller, and the controller can talk to the
model, but when you le the view and model talk, it starts to spin out of
control.

I like to call a business method and get back a collection of beans, so
that the Action does not even have to bother with that.But since the
contoller and the model are on adjacent layers, the Action could also
walk through a result set, if that works for you. The only thing is to
get the connection back into the pool as soon as possible.

For transfering data between beans, the BeanUtils can also be helpful.


Phase Communcations wrote:
>
> A quick hypothetical scenario:
>
> I have an action class that needs to pass a list of addresses to the view
> for display.
> I have a logic bean that contains a sql call to a database and retrieves
> address info.
> The resulset returns the following fields in each record: NAME, ADDRESS,
> CITY, STATE, ZIP
> I have a "databean" that has the following methods: setName(),
setAddress(),
> setCity(), setState(), setZip()
> An ArrayList(Collection) is created.
> For each record in the resultset the fields are used to populate the
> databean (ie NAME -> setName()) by calling it's property setting methods.
> Each bean populated is added to the ArrayList.
> Upon the end of the resultset the ArrayList is passed into a scope
(request
> for example) by the Action class and named "addresslist".
> The list of addresses then become available to the view for iteration and
> display.
>
> Where am I crossing boundaries in this scenario?
>
> Brandon Goodin
> Phase Web and Multimedia
> P (406) 862-2245
> F (406) 862-0354
> mail@phase.ws
> http://www.phase.ws
>
> -----Original Message-----
> From: jeff@the-kruegers.com [mailto:jeff@the-kruegers.com]
> Sent: Wednesday, February 13, 2002 12:02 PM
> To: 'Struts Users Mailing List'
> Subject: RE: SQL in Logic Bean or Action class
>
> You are on the right track.  Keep the sql with the model.  The only thing
is
> don't let your collection of "databeans" make it to the jsp.  That would
> then tie your presentation to the model.  Very bad.  There should be
another
> set of beans that represents more of what the view is like.  Often times
in
> the view beans all the data types will be string to make the validation a
> lot easier.
>
> Jeff Krueger
>
> -----Original Message-----
> From: Phase Communcations [mailto:mail@phase.ws]
> Sent: Wednesday, February 13, 2002 11:40 AM
> To: Struts Users Mailing List
> Subject: SQL in Logic Bean or Action class
>
> Just a simple design question. Having read through several posts and
reading
> the Struts documentation. I was wondering what is the best design pattern
> regarding SQL placement. My thoughts were that I need to keep SQL out of
the
> action class and pass all resultset data into Collections of beans. This
> helps keep from having tons of connections and resulsets sitting out there
> tieing up valuable database resources. The collection of "databeans" are
> then placed in a scope using the Controller(Action class)and made
available
> to other logic processes in the scope and/or passed on to the view for
data
> display. I am assuming this is because "business logic beans should be
> designed and implemented so that they do not know they are being executed
in
> a web application environment." Is my interpretation that SQL is part of
the
> Model and should be placed in Logic beans tweaked? Or is this a 6 and half
> dozen scenario? Or is there another pattern that I am missing altogether?
>
> Brandon Goodin
> Phase Web and Multimedia
> P (406) 862-2245
> F (406) 862-0354
> mail@phase.ws
> http://www.phase.ws
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/

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



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



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


RE: SQL in Logic Bean or Action class

Posted by Phase Communcations <ma...@phase.ws>.
Hey sean,

The following is some dialog I had with a couple of guys on the message
board about sql placement. I thought you might find it interesting.
Ultimately, just read Ted Husted.

Also, I have some thoughts I would like to pass by you when you have a few
moments. I have to make some changes to my content management. I have run
into a minor snag.

Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws


-----Original Message-----
From: Ted Husted [mailto:husted@apache.org]
Sent: Wednesday, February 13, 2002 8:55 PM
To: Struts Users Mailing List
Subject: Re: SQL in Logic Bean or Action class


It sounds fine to me.

The important thing is to follow the layers pattern

[ view ] | [ controller ] | [ model ]

The view can talk to the controller, and the controller can talk to the
model, but when you le the view and model talk, it starts to spin out of
control.

I like to call a business method and get back a collection of beans, so
that the Action does not even have to bother with that.But since the
contoller and the model are on adjacent layers, the Action could also
walk through a result set, if that works for you. The only thing is to
get the connection back into the pool as soon as possible.

For transfering data between beans, the BeanUtils can also be helpful.


Phase Communcations wrote:
>
> A quick hypothetical scenario:
>
> I have an action class that needs to pass a list of addresses to the view
> for display.
> I have a logic bean that contains a sql call to a database and retrieves
> address info.
> The resulset returns the following fields in each record: NAME, ADDRESS,
> CITY, STATE, ZIP
> I have a "databean" that has the following methods: setName(),
setAddress(),
> setCity(), setState(), setZip()
> An ArrayList(Collection) is created.
> For each record in the resultset the fields are used to populate the
> databean (ie NAME -> setName()) by calling it's property setting methods.
> Each bean populated is added to the ArrayList.
> Upon the end of the resultset the ArrayList is passed into a scope
(request
> for example) by the Action class and named "addresslist".
> The list of addresses then become available to the view for iteration and
> display.
>
> Where am I crossing boundaries in this scenario?
>
> Brandon Goodin
> Phase Web and Multimedia
> P (406) 862-2245
> F (406) 862-0354
> mail@phase.ws
> http://www.phase.ws
>
> -----Original Message-----
> From: jeff@the-kruegers.com [mailto:jeff@the-kruegers.com]
> Sent: Wednesday, February 13, 2002 12:02 PM
> To: 'Struts Users Mailing List'
> Subject: RE: SQL in Logic Bean or Action class
>
> You are on the right track.  Keep the sql with the model.  The only thing
is
> don't let your collection of "databeans" make it to the jsp.  That would
> then tie your presentation to the model.  Very bad.  There should be
another
> set of beans that represents more of what the view is like.  Often times
in
> the view beans all the data types will be string to make the validation a
> lot easier.
>
> Jeff Krueger
>
> -----Original Message-----
> From: Phase Communcations [mailto:mail@phase.ws]
> Sent: Wednesday, February 13, 2002 11:40 AM
> To: Struts Users Mailing List
> Subject: SQL in Logic Bean or Action class
>
> Just a simple design question. Having read through several posts and
reading
> the Struts documentation. I was wondering what is the best design pattern
> regarding SQL placement. My thoughts were that I need to keep SQL out of
the
> action class and pass all resultset data into Collections of beans. This
> helps keep from having tons of connections and resulsets sitting out there
> tieing up valuable database resources. The collection of "databeans" are
> then placed in a scope using the Controller(Action class)and made
available
> to other logic processes in the scope and/or passed on to the view for
data
> display. I am assuming this is because "business logic beans should be
> designed and implemented so that they do not know they are being executed
in
> a web application environment." Is my interpretation that SQL is part of
the
> Model and should be placed in Logic beans tweaked? Or is this a 6 and half
> dozen scenario? Or is there another pattern that I am missing altogether?
>
> Brandon Goodin
> Phase Web and Multimedia
> P (406) 862-2245
> F (406) 862-0354
> mail@phase.ws
> http://www.phase.ws
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/

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



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


Re: SQL in Logic Bean or Action class

Posted by Ted Husted <hu...@apache.org>.
It sounds fine to me. 

The important thing is to follow the layers pattern

[ view ] | [ controller ] | [ model ]

The view can talk to the controller, and the controller can talk to the
model, but when you le the view and model talk, it starts to spin out of
control. 

I like to call a business method and get back a collection of beans, so
that the Action does not even have to bother with that.But since the
contoller and the model are on adjacent layers, the Action could also
walk through a result set, if that works for you. The only thing is to
get the connection back into the pool as soon as possible. 

For transfering data between beans, the BeanUtils can also be helpful. 


Phase Communcations wrote:
> 
> A quick hypothetical scenario:
> 
> I have an action class that needs to pass a list of addresses to the view
> for display.
> I have a logic bean that contains a sql call to a database and retrieves
> address info.
> The resulset returns the following fields in each record: NAME, ADDRESS,
> CITY, STATE, ZIP
> I have a "databean" that has the following methods: setName(), setAddress(),
> setCity(), setState(), setZip()
> An ArrayList(Collection) is created.
> For each record in the resultset the fields are used to populate the
> databean (ie NAME -> setName()) by calling it's property setting methods.
> Each bean populated is added to the ArrayList.
> Upon the end of the resultset the ArrayList is passed into a scope (request
> for example) by the Action class and named "addresslist".
> The list of addresses then become available to the view for iteration and
> display.
> 
> Where am I crossing boundaries in this scenario?
> 
> Brandon Goodin
> Phase Web and Multimedia
> P (406) 862-2245
> F (406) 862-0354
> mail@phase.ws
> http://www.phase.ws
> 
> -----Original Message-----
> From: jeff@the-kruegers.com [mailto:jeff@the-kruegers.com]
> Sent: Wednesday, February 13, 2002 12:02 PM
> To: 'Struts Users Mailing List'
> Subject: RE: SQL in Logic Bean or Action class
> 
> You are on the right track.  Keep the sql with the model.  The only thing is
> don't let your collection of "databeans" make it to the jsp.  That would
> then tie your presentation to the model.  Very bad.  There should be another
> set of beans that represents more of what the view is like.  Often times in
> the view beans all the data types will be string to make the validation a
> lot easier.
> 
> Jeff Krueger
> 
> -----Original Message-----
> From: Phase Communcations [mailto:mail@phase.ws]
> Sent: Wednesday, February 13, 2002 11:40 AM
> To: Struts Users Mailing List
> Subject: SQL in Logic Bean or Action class
> 
> Just a simple design question. Having read through several posts and reading
> the Struts documentation. I was wondering what is the best design pattern
> regarding SQL placement. My thoughts were that I need to keep SQL out of the
> action class and pass all resultset data into Collections of beans. This
> helps keep from having tons of connections and resulsets sitting out there
> tieing up valuable database resources. The collection of "databeans" are
> then placed in a scope using the Controller(Action class)and made available
> to other logic processes in the scope and/or passed on to the view for data
> display. I am assuming this is because "business logic beans should be
> designed and implemented so that they do not know they are being executed in
> a web application environment." Is my interpretation that SQL is part of the
> Model and should be placed in Logic beans tweaked? Or is this a 6 and half
> dozen scenario? Or is there another pattern that I am missing altogether?
> 
> Brandon Goodin
> Phase Web and Multimedia
> P (406) 862-2245
> F (406) 862-0354
> mail@phase.ws
> http://www.phase.ws
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/

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


RE: SQL in Logic Bean or Action class

Posted by je...@the-kruegers.com.
You are crossing the boundary in your action class when you put the result
sets arraylist in the session.  In the action class you should transfer that
information into a different array list of view classes and put that in the
session.  I know it sounds like a lot of work and overhead to instance all
those classes, but it is worth it and there is a helper class that might be
of some use to you, I believe it is called like beanPopulate or something,
maybe someone else can give you more info on that.  I haven't used it yet.

Jeff Krueger


-----Original Message-----
From: Phase Communcations [mailto:mail@phase.ws]
Sent: Wednesday, February 13, 2002 12:15 PM
To: Struts Users Mailing List; jeff@the-kruegers.com
Subject: RE: SQL in Logic Bean or Action class


A quick hypothetical scenario:

I have an action class that needs to pass a list of addresses to the view
for display.
I have a logic bean that contains a sql call to a database and retrieves
address info.
The resulset returns the following fields in each record: NAME, ADDRESS,
CITY, STATE, ZIP
I have a "databean" that has the following methods: setName(), setAddress(),
setCity(), setState(), setZip()
An ArrayList(Collection) is created.
For each record in the resultset the fields are used to populate the
databean (ie NAME -> setName()) by calling it's property setting methods.
Each bean populated is added to the ArrayList.
Upon the end of the resultset the ArrayList is passed into a scope (request
for example) by the Action class and named "addresslist".
The list of addresses then become available to the view for iteration and
display.

Where am I crossing boundaries in this scenario?

Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws


-----Original Message-----
From: jeff@the-kruegers.com [mailto:jeff@the-kruegers.com]
Sent: Wednesday, February 13, 2002 12:02 PM
To: 'Struts Users Mailing List'
Subject: RE: SQL in Logic Bean or Action class


You are on the right track.  Keep the sql with the model.  The only thing is
don't let your collection of "databeans" make it to the jsp.  That would
then tie your presentation to the model.  Very bad.  There should be another
set of beans that represents more of what the view is like.  Often times in
the view beans all the data types will be string to make the validation a
lot easier.

Jeff Krueger

-----Original Message-----
From: Phase Communcations [mailto:mail@phase.ws]
Sent: Wednesday, February 13, 2002 11:40 AM
To: Struts Users Mailing List
Subject: SQL in Logic Bean or Action class


Just a simple design question. Having read through several posts and reading
the Struts documentation. I was wondering what is the best design pattern
regarding SQL placement. My thoughts were that I need to keep SQL out of the
action class and pass all resultset data into Collections of beans. This
helps keep from having tons of connections and resulsets sitting out there
tieing up valuable database resources. The collection of "databeans" are
then placed in a scope using the Controller(Action class)and made available
to other logic processes in the scope and/or passed on to the view for data
display. I am assuming this is because "business logic beans should be
designed and implemented so that they do not know they are being executed in
a web application environment." Is my interpretation that SQL is part of the
Model and should be placed in Logic beans tweaked? Or is this a 6 and half
dozen scenario? Or is there another pattern that I am missing altogether?

Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws



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



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





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


RE: SQL in Logic Bean or Action class

Posted by Phase Communcations <ma...@phase.ws>.
A quick hypothetical scenario:

I have an action class that needs to pass a list of addresses to the view
for display.
I have a logic bean that contains a sql call to a database and retrieves
address info.
The resulset returns the following fields in each record: NAME, ADDRESS,
CITY, STATE, ZIP
I have a "databean" that has the following methods: setName(), setAddress(),
setCity(), setState(), setZip()
An ArrayList(Collection) is created.
For each record in the resultset the fields are used to populate the
databean (ie NAME -> setName()) by calling it's property setting methods.
Each bean populated is added to the ArrayList.
Upon the end of the resultset the ArrayList is passed into a scope (request
for example) by the Action class and named "addresslist".
The list of addresses then become available to the view for iteration and
display.

Where am I crossing boundaries in this scenario?

Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws


-----Original Message-----
From: jeff@the-kruegers.com [mailto:jeff@the-kruegers.com]
Sent: Wednesday, February 13, 2002 12:02 PM
To: 'Struts Users Mailing List'
Subject: RE: SQL in Logic Bean or Action class


You are on the right track.  Keep the sql with the model.  The only thing is
don't let your collection of "databeans" make it to the jsp.  That would
then tie your presentation to the model.  Very bad.  There should be another
set of beans that represents more of what the view is like.  Often times in
the view beans all the data types will be string to make the validation a
lot easier.

Jeff Krueger

-----Original Message-----
From: Phase Communcations [mailto:mail@phase.ws]
Sent: Wednesday, February 13, 2002 11:40 AM
To: Struts Users Mailing List
Subject: SQL in Logic Bean or Action class


Just a simple design question. Having read through several posts and reading
the Struts documentation. I was wondering what is the best design pattern
regarding SQL placement. My thoughts were that I need to keep SQL out of the
action class and pass all resultset data into Collections of beans. This
helps keep from having tons of connections and resulsets sitting out there
tieing up valuable database resources. The collection of "databeans" are
then placed in a scope using the Controller(Action class)and made available
to other logic processes in the scope and/or passed on to the view for data
display. I am assuming this is because "business logic beans should be
designed and implemented so that they do not know they are being executed in
a web application environment." Is my interpretation that SQL is part of the
Model and should be placed in Logic beans tweaked? Or is this a 6 and half
dozen scenario? Or is there another pattern that I am missing altogether?

Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws



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



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




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


RE: SQL in Logic Bean or Action class

Posted by je...@the-kruegers.com.
You are on the right track.  Keep the sql with the model.  The only thing is
don't let your collection of "databeans" make it to the jsp.  That would
then tie your presentation to the model.  Very bad.  There should be another
set of beans that represents more of what the view is like.  Often times in
the view beans all the data types will be string to make the validation a
lot easier.

Jeff Krueger

-----Original Message-----
From: Phase Communcations [mailto:mail@phase.ws]
Sent: Wednesday, February 13, 2002 11:40 AM
To: Struts Users Mailing List
Subject: SQL in Logic Bean or Action class


Just a simple design question. Having read through several posts and reading
the Struts documentation. I was wondering what is the best design pattern
regarding SQL placement. My thoughts were that I need to keep SQL out of the
action class and pass all resultset data into Collections of beans. This
helps keep from having tons of connections and resulsets sitting out there
tieing up valuable database resources. The collection of "databeans" are
then placed in a scope using the Controller(Action class)and made available
to other logic processes in the scope and/or passed on to the view for data
display. I am assuming this is because "business logic beans should be
designed and implemented so that they do not know they are being executed in
a web application environment." Is my interpretation that SQL is part of the
Model and should be placed in Logic beans tweaked? Or is this a 6 and half
dozen scenario? Or is there another pattern that I am missing altogether?

Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws



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



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


SQL in Logic Bean or Action class

Posted by Phase Communcations <ma...@phase.ws>.
Just a simple design question. Having read through several posts and reading
the Struts documentation. I was wondering what is the best design pattern
regarding SQL placement. My thoughts were that I need to keep SQL out of the
action class and pass all resultset data into Collections of beans. This
helps keep from having tons of connections and resulsets sitting out there
tieing up valuable database resources. The collection of "databeans" are
then placed in a scope using the Controller(Action class)and made available
to other logic processes in the scope and/or passed on to the view for data
display. I am assuming this is because "business logic beans should be
designed and implemented so that they do not know they are being executed in
a web application environment." Is my interpretation that SQL is part of the
Model and should be placed in Logic beans tweaked? Or is this a 6 and half
dozen scenario? Or is there another pattern that I am missing altogether?

Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws



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