Struts has ActionForm beans but no ActionResult beans.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   pierre_sirolli
Posted On:   Wednesday, January 23, 2002 07:40 AM

Hi Ted, I saw a lot of questions and your answers about sending the result to the jsp. I already asked you about storing the results in the ActionForm. You said that was OK for you. I do agree but I think it is a bit confusing to some extends. Do you think it could usefull to create in struts a ActionResult (whateever is its name) bean which will contain all the data required to display the response (eg to create the JSP)? This ActionResult bean will be specified in the ActionMapping configuration (of course !). Actually, what I am using in addition with Struts is the command pattern : in the perform() method of the action I do : MyCommand cmd = ne   More>>

Hi Ted,


I saw a lot of questions and your answers about sending the result to the jsp.

I already asked you about storing the results in the ActionForm.

You said that was OK for you. I do agree but I think it is a bit confusing to some extends.

Do you think it could usefull to create in struts a ActionResult (whateever is its name) bean which will contain all the data required to display the response (eg to create the JSP)?

This ActionResult bean will be specified in the ActionMapping configuration (of course !).


Actually, what I am using in addition with Struts is the command pattern :

in the perform() method of the action I do :


MyCommand cmd = new MyCommand();

cmd.execute(); // this invokes the business layer and fill up the outputs properties of the command



then request.setAttribute(COMMAND_KEY, cmd);



Thanks in advance


Pierre

   <<Less

Re: Struts has ActionForm beans but no ActionResult beans.

Posted By:   Ted_Husted  
Posted On:   Thursday, January 24, 2002 02:00 AM


It is useful to create a Result bean that contains all the
data you need for th response. But the Struts beans tags,
and other presentation systems, are designed to
use any JavaBean. So, you can just create whatever
bean suits your needs.



In the beginning, the framework tried using plain beans,
but found that we really needed the validate() and
reset() methods to make the input/correct cycle work.
But for output this doesn't apply, so there is not
much to be gained by just having the ActionServlet
create some arbitrrary bean for you.



Also, going into an Action you don't always know what
page will be used in the result. The Action really
needs to determine what bean to create based on
what page it decides to forward to.



There are useful, reusable object you can create to carry
results to the presentation layer. One such is the
ModeResult object in my Scaffold package. It has
properties for a title, and a collection, and so forth. But
there can be many such as this, and it would be wrong for
the framework to endorse just one :)



If you do find it convenient to specify a result bean
in the ActionMapping, you can extend the ActionMapping
class and include new properties, if you like.



HTH -Ted

About | Sitemap | Contact