Will Stranathan wrote: <snip>
My apologies for not reading first - yeah - use a dynamic one like jack said. I would PROBABLY subclass Action with an abstract subclass - something like:Thanks, I understand what I should be doing... but you threw me a slight curve. :-) I really don't want you to show me how to write java... but I'm not that good at it so I only 'sorta' know how to do what you've said. I'm going to try and decode all this with my java book and see where I wind up. Basically what you're saying is instead of having:
public ... execute(...) { // This overrides Action.execute()
// Do whatever up-front checking ... // Now, call my own REAL execute method: forward = this.doWork(mapping, form, request, response);
// Store the path of the forward in the user's session // so that on their next communication back to us, // the go right back to the same place request.getSession().setAttribute("i_was_here", forward.getPath()); }
// Here's a method for your doWork() implementation to
// just return a new forward for where they were before.
// You don't HAVE to call this, of course.
protected ActionMapping getDefaultForward(mapping, request) {
try {
return new ActionForward((String)request.getSession(true).getAttribute("i_was_here"));
} catch (Excetpion e) { // Could be an NPE (attribute doesn't exist) // or a ClassCastException (attribute doesn't cast to a String) return mapping.findForward("default"); } }
public abstract void doWork(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception;
public final class SearchAction extends Action {
public ActionForward execute( final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws Exception { // DO ALL MY WORK HERE } }
I'd create something like: public SomeName execute( final blah blah, final blah blah) throws Exception { ArrayList resultset = SearchData.getSearchAccount( searchstring, getDataSource(request,"trustmaster"), errors);
if (resultset == null)
errors.add(
ActionErrors.GLOBAL_ERROR,
new ActionError("error.resultset.null"));
} else {
session.setAttribute("results", resultset);
}
// Then Call this REAL execute method:
forward = this.doWork(mapping, form, request, response);
public abstract void doWork(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception;
That's what I want to do... I just don't know how to do that. :-( Sorry guys, this is not related to struts, but does anyone have an example class I could look off of? Thanks a ton, great answers. Brandon
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]