While I 100% agree with the theory and separate the layers as much as possible in my own code, I can't say I've never broken the rules (and I doubt any of you can frankly). I also know that in development, especially in a corporate environment where the emphasis many times is on just getting things done rather than getting things right (even when we as techies know that's now a good thing), you sometimes need to do what is possibly a little quicker and easier.

All that being said, here's the answer to your question... Simply put, you instantiate the Action like you would any other class and call it's execute() method. That's about all there is to it. You can either disregard the ActionForward it returns, or use it, whatever it appropriate.

Think of it this way... If Action A executes and then calles Action B, for all intents and purposes, Action B acts like it's servicing a new request, with Action A, in a way I guess, playing the part of the Struts framework in the sense that it's delegating to an Action to handle the request. Kind of a weird explanation I guess, but the take-away point here is that an Action is just another class. Instantiate and call execute() (passing it all the objects the execute() method of Action A recieved of course) and that's that. I've done this, works just fine.

BUT DON'T DO IT! The other posters are dead-on... If there's any way at all you can avoid doing this, do so. You'll thank yourself later.

--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

Karr, David wrote:
It may not have been the answer the original poster was looking for, but
it is the correct way to solve this problem.  Action methods should only
be used as direct responses to a single user action.  Business delegate
behaviors should be aggregated and reused by different actions.


-----Original Message-----
From: Jin Bal [mailto:[EMAIL PROTECTED]


The trick is to make your action classes very "thin" i.e. implement as much logic as you possible can in your delegate without violating separation of concerns. This way it becomes less of a problem making your actions fine grained and have a number of actions reusing logic in your delegate layer.

Prob not the ans you were looking but HTH anyway.

Jin Bal
----- Original Message ----- From: "Marco Mistroni" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Friday, October 08, 2004 12:32 PM
Subject: Struts /silly question




Hello all,
I am sure this is a very easy question, but I cannot
Figure out the solution...

I have a XAction class which is in charge of calling a business delegate, Get some data and put it into the session..

Now, I want to be able to call this XAction class from different action class (to avoid duplicate the code that loads the

data and put


it into the Session).

Question is: how do I invoke an action2 from action1, and

then return


control action 1?

Thanx in advance and regards
Marco






---------------------------------------------------------------------

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]



Reply via email to