Re: trouble with dispatching on a paramter
Thank you so much, as soon as I removed the execute method it worked perfectly Wendy Smoak wrote: From: "Troy Bull" <[EMAIL PROTECTED]> public ActionForward execute( ... ) { SearchForm s = (SearchForm) form; String dispatchString = s.getDispatch(); System.out.println("Main Dispatch String : " + dispatchString); // manually dispatching works but is ugly //if ("run_main_search".equals(dispatchString)) { return runMainSearch(mapping, form, request, response);} //if ("save_defaults".equals(dispatchString)) { return setAsDefaults(mapping, form, request, response);} return mapping.findForward("error"); } public ActionForward runMainSearch(... ) { ... } I still think you're overriding 'execute' and never calling super.execute(...) to give DispatchAction a chance to do its job. Does it work if you remove the 'execute' method entirely from your DoSearchAction (and fix the 'dispatch' param value so it matches the method name)? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: trouble with dispatching on a paramter
From: "Troy Bull" <[EMAIL PROTECTED]> public ActionForward execute( ... ) { SearchForm s = (SearchForm) form; String dispatchString = s.getDispatch(); System.out.println("Main Dispatch String : " + dispatchString); // manually dispatching works but is ugly //if ("run_main_search".equals(dispatchString)) { return runMainSearch(mapping, form, request, response);} //if ("save_defaults".equals(dispatchString)) { return setAsDefaults(mapping, form, request, response);} return mapping.findForward("error"); } public ActionForward runMainSearch(... ) { ... } I still think you're overriding 'execute' and never calling super.execute(...) to give DispatchAction a chance to do its job. Does it work if you remove the 'execute' method entirely from your DoSearchAction (and fix the 'dispatch' param value so it matches the method name)? -- Wendy Smoak - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: trouble with dispatching on a paramter
Troy Bull wrote: Hello I am trying to get my form to dispatch to different functions inside my action handler class. I followed this tip exactly : http://www.husted.com/struts/tips/002.html (except i fixed a couple type o's). The problem is my dispatch parameter is not being recognized. I have the following code in my ActionForward execute method: SearchForm s = (SearchForm) form; String dispatchString = (String) request.getAttribute("dispatch"); Are you searching for request parameter - the subject of your email is "rouble with dispatching on a paramter"? why do you use request.getAttribute("dispatch") in this case? try request.getParameter("dispatch"); (for sure it's there is its populated also in the form, since the form is populated from request parameters) Borislav - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: trouble with dispatching on a paramter
Here is the class declaration : public class DoSearchAction extends DispatchAction { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { SearchForm s = (SearchForm) form; String dispatchString = s.getDispatch(); System.out.println("Main Dispatch String : " + dispatchString); // manually dispatching works but is ugly //if ("run_main_search".equals(dispatchString)) { return runMainSearch(mapping, form, request, response);} //if ("save_defaults".equals(dispatchString)) { return setAsDefaults(mapping, form, request, response);} return mapping.findForward("error"); } public ActionForward runMainSearch(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { SearchForm s = (SearchForm) form; System.out.println(s.getDispatch()); return mapping.findForward("gms"); } public ActionForward setAsDefaults(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { System.out.println("Hello from save defaults"); return mapping.findForward("confirm_save_defaults"); } } Any ideas? Wendy Smoak wrote: From: "Troy Bull" <[EMAIL PROTECTED]> The problem is my dispatch parameter is not being recognized. I have the following code in my ActionForward execute method: SearchForm s = (SearchForm) form; String dispatchString = (String) request.getAttribute("dispatch"); Try request.getParameter("dispatch"); instead if you want to see what was submitted with the form. (Request parameters are not the same as request attributes.) But it looks okay, because the form bean property was populated. what I want is the method run_main_search to execute instead. Java naming conventions would point to runMainSearch, but okay. :) Does your DoSearchAction extend DispatchAction? (You mention your "ActionForward" execute method-- typo?) If you've overridden the 'execute' method to print debugging statements, are you calling super.execute(...)? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: trouble with dispatching on a paramter
From: "Troy Bull" <[EMAIL PROTECTED]> The problem is my dispatch parameter is not being recognized. I have the following code in my ActionForward execute method: SearchForm s = (SearchForm) form; String dispatchString = (String) request.getAttribute("dispatch"); Try request.getParameter("dispatch"); instead if you want to see what was submitted with the form. (Request parameters are not the same as request attributes.) But it looks okay, because the form bean property was populated. what I want is the method run_main_search to execute instead. Java naming conventions would point to runMainSearch, but okay. :) Does your DoSearchAction extend DispatchAction? (You mention your "ActionForward" execute method-- typo?) If you've overridden the 'execute' method to print debugging statements, are you calling super.execute(...)? -- Wendy Smoak - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]