the way we work around this limitation is to make multiple form defines in the struts-config.xml
<form-bean name="someAddForm" type="something.SomeForm" /> <form-bean name="someEditForm" type="something.SomeForm" /> <form-bean name="someDeleteForm" type="something.SomeForm" /> You can use the same form bean - SomeForm - but identify it by different names depending upon the action that is invoked. <action path="/some/add" type="something.SomeAction" scope="request" name="someAddForm" validate="true" input="/jsp/some/add.jsp" parameter="Add"> ... andrew -----Original Message----- From: Struts Newsgroup (@Basebeans.com) [mailto:[EMAIL PROTECTED]] Sent: Friday, March 08, 2002 10:40 AM To: [EMAIL PROTECTED] Subject: Re: What's a good practice to reuse formBeans with validation Subject: Re: What's a good practice to reuse formBeans with validation From: "Pim" <[EMAIL PROTECTED]> === Looks like a fine solution, but.. I'm using davids winterfeldt's validator. This means that you can (and must) validate per ActionForm. So I'm forced to using multiple ActionForms since I have different validations (insert/update and delete) gr, Pim "Jonathan Fuerth" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]... > On Fri, Mar 08, 2002 at 12:55:01AM -0800, Struts Newsgroup wrote: > > What we wanted was exactly the same as you: insert, update, delete, > > different actions with different validations. If I want different > > validations I want different formbeans (formbean for insert, one for > > update and one for delete). The problem is that the html form > > section (<html:form action = "youraction">)can only contain one > > action and so you can only go to one formbean. If this form has > > multiple buttons then what do you do? > > We've encountered the same problem, and here's how we chose to solve > it (using only one formbean): > > -For each submit button, assign a different property name: > <html:submit property="insertSubmit"> > <bean:message key="button.newRecord"/> > </html:submit> > > <html:submit property="updateSubmit"> > <bean:message key="button.updateRecord"/> > </html:submit> > > <html:submit property="deleteSubmit"> > <bean:message key="button.deleteRecord"/> > </html:submit> > > -Then in your validate(mapping,request) method of the form bean: > public ActionErrors validate(ActionMapping mapping, HttpServletRequest req){ > boolean doInsert=(req.getParameter("insertSubmit") != null); > boolean doUpdate=(req.getParameter("updateSubmit") != null); > boolean doDelete=(req.getParameter("deleteSubmit") != null); > > // Check for always-required fields here > > if(doInsert || doUpdate) { > //Check for some special-case required fields here > } > if(doDelete) { > //Check for different set of required fields here > } > } > > -This method has worked really well for us: it's easy to implement, > and easy to understand for new people who join the project. > > > The area we haven't checked is the area of using hyperlinks instead of > > submit buttons, so the solution might be there. > > This could work if you required your users to have a > javascript-enabled browser, but the method I'm using works with all > forms-enabled browsers... which is most (but not all) of them. :) > > -- > Jonathan Fuerth - SQL Power Group Inc. > (416)218-5551 (Toronto); 1-866-SQL-POWR (Toll-Free) > Unleash the Power of your Corporate Data - www.sqlpower.ca > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>