You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Billy Ng <kw...@earthlink.net> on 2002/10/04 19:27:20 UTC

Business Logic Bean Question

Hi folks,

I have been reading some articles briefly talking about the business logic beans.  The way I build my Struts app is to use the Action's perform or execute method to do the business logic.  Then, I set the data into a bean and pass it off to the JSP.  It works just fine.  However, my question is if I should do the business logic in Action?  Am I supposed to hand down the job to a business logic bean?  It will be helpful if anyone can provide me samples or links for how a business logic looks alike.

Thanks in advance!

Billy Ng

Re: Business Logic Bean Question

Posted by Adam Sherman <ad...@teachandtravel.com>.
Billy Ng wrote:
 > I have been reading some articles briefly talking about the business
 > logic beans.  The way I build my Struts app is to use the Action's
 > perform or execute method to do the business logic.  Then, I set the
 > data into a bean and pass it off to the JSP.  It works just fine.
 > However, my question is if I should do the business logic in Action?
 > Am I supposed to hand down the job to a business logic bean?  It will
 > be helpful if anyone can provide me samples or links for how a
 > business logic looks alike.

A good rule is to never have anything in javax.servlet imported into a 
class that does business logic.

Actions call Business Objects which pass back Value Objects. Value 
Objects are created with Manager Objects.

My two cents,

A.

-- 
Adam Sherman
Software Developer
Teach and Travel Inc.
+1.613.241.3103



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


Re: Business Logic Bean Question

Posted by John Owen <jo...@hotmail.com>.
Ideally, you would want to create a subsystem that your perform() or
execute() method interfaces with. Usually this subsystem consists of a
business delegate that returns data usable by any view, an optional session
facade and either ejbs or a collection of classes for retrieving data,
called Data Access Objects or DAOs. I glossed over the entire architecture,
but you can read up on J2EE design patterns at :

http://java.sun.com/blueprints/corej2eepatterns/

The simplest progression for you would be to move your business logic and
data access into a delegate and call the delegate from within your perform()
or execute() method. After you get that working, you can approach delegating
some of the work done by the business delegate into other classes or by
using advanced design principles.

John
----- Original Message -----
From: "Billy Ng" <kw...@earthlink.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, October 04, 2002 12:27 PM
Subject: Business Logic Bean Question


Hi folks,

I have been reading some articles briefly talking about the business logic
beans.  The way I build my Struts app is to use the Action's perform or
execute method to do the business logic.  Then, I set the data into a bean
and pass it off to the JSP.  It works just fine.  However, my question is if
I should do the business logic in Action?  Am I supposed to hand down the
job to a business logic bean?  It will be helpful if anyone can provide me
samples or links for how a business logic looks alike.

Thanks in advance!

Billy Ng


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


Re: Business Logic Bean Question

Posted by Billy Ng <kw...@earthlink.net>.
Thanks all of you,  I think I got the picture!

Billy Ng

----- Original Message -----
From: "Pavel Kolesnikov" <k...@les.cz>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, October 04, 2002 10:47 AM
Subject: Re: Business Logic Bean Question


> On Fri, 4 Oct 2002, Billy Ng wrote:
>
> > I have been reading some articles briefly talking about the business
> > logic beans.  The way I build my Struts app is to use the Action's
> > perform or execute method to do the business logic.  Then, I set the
> > data into a bean and pass it off to the JSP.  It works just fine.
> > However, my question is if I should do the business logic in Action?
> > Am I supposed to hand down the job to a business logic bean?
>
> Yes, it's a good practice.
>
> >  It will be helpful if anyone can provide me samples or links for how a
> > business logic looks alike.
>
> It can be any common class. OK, it would be nice if it followed
> some simple rules like
>
>  - don't accept any client specific (e.g. http related) parameters
>  - don't expose business logic implementation details (e.g. SQL
>    or EJB related exceptions)
>
> I recommend you EJB Design Patterns book from Floyd Marinescu
> (you can download it for free from www.theserverside.com), try
> to find something about "Business Delegate" pattern there.
>
> Pavel
>
>
>
> --
> 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: Business Logic Bean Question

Posted by Pavel Kolesnikov <k...@les.cz>.
On Fri, 4 Oct 2002, Billy Ng wrote:

> I have been reading some articles briefly talking about the business
> logic beans.  The way I build my Struts app is to use the Action's
> perform or execute method to do the business logic.  Then, I set the
> data into a bean and pass it off to the JSP.  It works just fine.  
> However, my question is if I should do the business logic in Action?  
> Am I supposed to hand down the job to a business logic bean?

Yes, it's a good practice.

>  It will be helpful if anyone can provide me samples or links for how a 
> business logic looks alike.

It can be any common class. OK, it would be nice if it followed
some simple rules like 

 - don't accept any client specific (e.g. http related) parameters
 - don't expose business logic implementation details (e.g. SQL
   or EJB related exceptions)

I recommend you EJB Design Patterns book from Floyd Marinescu
(you can download it for free from www.theserverside.com), try
to find something about "Business Delegate" pattern there.

Pavel



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