Frank W. Zammetti wrote:
 >> Another way to do it might be to subclass ActionForward, calling it
 >> Result.  Then, after the Action executes, we try to cast the result to
 >> Result, and if we catch a ClassCastException, then we have a plain old
 >> ActionForward and we process it same as always, but if the exception
 >> didn't occur then we have a Result and we can go off and do "result
 >> things(tm)".

Just to change that slightly and clarify it with an example, we'd wind up with this:

class Result extends ActionForward {
  // Might not be anything here, just a marker in essence
}
class JSONResult extends Result {
  // Do JSON generation, whatever that means
}

...then in the Action...

public ActionForward execute(ActionMapping mapping, ActionForm inForm,
HttpServletRequest request, HttpServletResponse response) throws Exception {
  return JSONResult(inForm);
}

...then, in the RP chain, somewhere after the Action execution...

// af is the ActionForward returned by execute()
Result r = null;
try {
  r = (Result)af;
  processResult(r);
} catch (ClassCastException cce) {
  processActionForward(r);
}

I have no doubt I'm screwing up something simple here, since that's my MO, but if not, that's what I'm describing.

(I just saw your response by the way, so I'm anxious to see what you think of this, since it's more fleshed out and concrete)

Frank

Because to me, while what you propose isn't exactly rocket science to implement or make use of, I think this approach is simpler still, and requires very minimal changes to the codebase, also something I strive for (not just with Struts either)

...or did you have some other motivation for those changes besides this? Did you have other plans that hinge on these changes?

Frank

--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: [EMAIL PROTECTED]
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
 (2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

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




--
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: [EMAIL PROTECTED]
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
and "JavaScript, DOM Scripting and Ajax Projects"
 (2007, Apress, ISBN 1-59059-816-4)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

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

Reply via email to