At 2:57 PM +0100 2/11/04, Turner Benjamin wrote:

well i have an action that compiles all the data necessary for a page (presents a newsletter being created), newsletter.do. i also have an action that attaches an image to the newsletter (image.do), which after putting the image in the db as a blob forwards control back to newsletter.do to reload the newsletter and show it.


without the multipart spec the code works (but of course i can't upload a file), and the chain forwarding to the other action works as well.

Can you refactor so that you can achieve the necessary business logic some other way? Perhaps you can move the newsletter management code into a helper class so that the one action can call one method on it and the other action can call two methods.


Perhaps simpler at first, you could reorganize your Actions so that they share methods -- either make one Action extend the other, or use DispatchAction (or even just your own logic in execute()) to process the request in a class that can use method calls instead of request dispatching to achieve each of the necessary business goals.

I hope that's not too vague; it can be hard to be exact when you don't know the project. But in projects of any considerable scope, the designs tend to pushing almost everything into model classes that don't know anything about HTTP or Struts, and then all the Actions do is gather and translate HTTP, request parameters, and session attributes and then use those things to call "business methods" on the model classes.

It's good to be able to do quick and dirty, but there are limits, and chaining actions is one of the limits; Struts doesn't do it well, and there hasn't been a lot of motivation to make it do it well because reorganizing your app is usually a better solution.

Joe

--
Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com "Imagine if every Thursday your shoes exploded if you tied them the usual way. This happens to us all the time with computers, and nobody thinks of complaining."
-- Jef Raskin


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



Reply via email to