Struts question


Web tier: servlets, JSP, Web frameworks: Struts question

  1. Struts question (1 messages)

    Hi, I am developing crud opeations with Struts 1.2.4. MY JSP IS MADE OF 1) INPUT FIELDS - campaing name - start date - end date 2) BUTTONS - load sector button (with html:submit in the JSP) - load branch button (with html:submit in the JSP) - watch lines button (with html:submit in the JSP) - save button (with html:submit in the JSP) - cancel button (with html:cancel in the JSP) I AM USING - LookUpDispatchAction to control the buttons in my JSP - ValidatorForm to validate the data input MY PROBLEM Everything is ok, but, when I click on “cancel button” of my JSP, Struts is executing the form validation and I am not allowed to cancel. I would like to know if I am doing something wrong... Thank you for your help, Jorge.
  2. Re: Struts question[ Go to top ]

    Hi Jorge bianculli, (OK, "Post reply" is working now...) What you need to know is that using LookupDispatchAction is incompatible with The reason is the name of the input tag that gets submitted. A translates to: But to use LookupDispatchAction, the name attribute must match the parameter attribute on your Struts mapping. Like so: My solution was have a base Action class for my app, and for all my Actions to subclass this one. It goes something like: public abstract class BaseAction extends LookupDispatchAction { protected Map getKeyMethodMap() { return null; } public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response ) throws Exception { if ( isCancelled( request ) ) { return mapping.findForward( Forwards.CANCEL ); } else if ( mapping.getParameter() == null || request.getParameter( mapping.getParameter() ) == null ) { return this.unspecified( mapping, form, request, response ); } else { return super.execute( mapping, form, request, response ); } } } Hope that helps :-)