I allways say validate = false in mapping, and then manualy call it. Would that help? .V
Bryce Fischer wrote:
I'm having a problem with a ValidatorForm and validation. The first time I try to access the action below, I get a validation error. The form never gets the opportunity to be filled in by the Action class (action called is /fringe.do?method=edit). Is there any way to tell Struts to not do validation unless we are saving? For example, calling /fringe.do?method=save? I have solved it by overrideing the validate() method, checking the parameters and seeing if "method = 'save'".
I was wondering if this was the only way to accomplish this? I'd like to be able to keep that kind of logic out of my form, and put it in the validation.xml file, or another configuration file...
Form:
public class FringeForm extends ValidatorForm implements java.io.Serializable {
private String field1;
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors actionErrors = new ActionErrors();
String method = request.getParameter("method");
if ("save".equals(method)) {
actionErrors = super.validate(mapping, request);
}
return actionErrors;
}
// getters and setters omitted for brevity }
Validation: <form-validation> <!-- Define global validation config in validation-global.xml --> <formset> <form name="fringeForm"> <field property="field1" depends="required"> <arg0 key="fringeForm.field1"/> </field> </form> </formset> </form-validation>
And the action mapping looks like this (actual class extends DispatchAction):
<action path="/fringe" type="org.springframework.web.struts.DelegatingActionProxy" name="fringeForm" scope="request" parameter="method" input="/WEB-INF/pages/fringeForm.jsp" > <forward name="edit" path="/WEB-INF/pages/fringeForm.jsp"/> <forward name="success" path="/index.jsp"/> </action>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]