struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Kyser <ktra...@comcast.net>
Subject Re: DynaActionForm not getting validated by struts validation plugin
Date Wed, 07 May 2003 16:11:47 GMT
I can't remember whether validate="true" is default or not,
so I always explicitly add it.

You don't have that in your action mapping.

if the default is 'true', then, sorry, ignore.

-jeff

On Wednesday, May 7, 2003, at 10:08  AM, Nick Curry wrote:

> hi there,
>
> I am trying to get a form implementing the DynaValidaForm class to
> validate, but the validation doesn't seem to take place at all. There
> were a couple of previous threads about this, but none seem to come to 
> a
> solution, so I will post the details of my problems here. I really 
> can't
> see what i'm doing wrong, perhaps someone else will see something
> blindingly obvious that i've missed...
>
> I am using Struts 1.1 (w/ JDK 1.4) using modules. The form I am trying
> to validate is called test_searchForm, and is defined in
> struts-conf-mymodule.xml as follows:
>
> __________________________________________________________________
> <form-bean name="test_searchForm"
> 	           type="org.apache.struts.validator.DynaValidatorForm">
>
> 			<form-property name="needle"
>
> 			               type="java.lang.String"/>
>
> 			<form-property name="column"
>
> 			               type="java.lang.String"/>
>
> 			<form-property name="table"
>
> 			               type="java.lang.String"/>
>
> 		</form-bean>
> __________________________________________________________________
>
>
> I am using that form in an action which is defined as such:
> __________________________________________________________________
> <action path="/test_searchTest"
>
> 		        type="sb_nick.search.searchTestAction"
>
> 		        name="test_searchForm"
>
> 		        scope="request"
>
> 		        input="/test_searchTestForm.vm">
>
> 			<forward name="test_showResults"
>
> 			         path="/test_searchTestResults.vm"
>
> 			         redirect="false"/>
>
> 			<forward name="test_failure"
>
> 			         path="/test_searchTestForm.vm"
>
> 			         redirect="false"/>
>
> 		</action>
> __________________________________________________________________
>
>
> (as you might notice, I am also using Velocity for the templates, 
> though
> I am having no problems with that)
>
> The relevant part of the sb_nick.search.searchTestAction.java file is 
> as
> follows:
> __________________________________________________________________
> public ActionForward execute(ActionMapping mapping,
> 				 ActionForm form,
> 				 HttpServletRequest request,
> 				 HttpServletResponse response)
> 	throws Exception {
> 	
>       // Validate the request parameters specified by the user
> 	ActionErrors errors = new ActionErrors();
> 	
> 	
> 	DynaValidatorForm myres=(DynaValidatorForm)form;
> 	String needle = (String)myres.get("needle");
> 	String column = (String)myres.get("column");
> 	String table = (String)myres.get("table");
>
> 	
> 	   //manually validation test
> 	   if (needle.length()<1){
> 		   errors.add(ActionErrors.GLOBAL_ERROR,
>                    new ActionError("test.error_required", "search
>
>                    string"));
> 	   }
> 	// Report any errors we have discovered back to the form
> 	if (!errors.isEmpty()) {
> 	    saveErrors(request, errors);
>             return (mapping.getInputForward());
> 	}
> __________________________________________________________________
>
> The manual validation part works fine (as in forwarding to the input 
> URI
> works and the error message gets passed through), however nothing else
> seems to get validated. The validator plugin is enabled, I tried 
> putting
> the validator rules and definitions in both the /WEB-INF folder of the
> main appliaction and locally to the modules. For the local version, the
> struts-config-mymodule.xml file looks as such:
> __________________________________________________________________
> <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
>
> 		<set-property property="pathnames" value="sb_nick-validation.xml,
>               sb_nick-validator-rules.xml"/>
>
> 	</plug-in>
> __________________________________________________________________
>
>
> The validation.xml files looks as such:
> __________________________________________________________________
>             <form name="test_searchForm">
>             <field
>                 property="needle"
>                 depends="required">
>              </field>
> 	     <field
>                 property="column"
>                 depends="required">
> 			<msg name="required" key="test.error_required">
>              </field>
> 	     <field
>                 property="table"
>                 depends="required">
>                     	<msg name="required" key="test.error_required">
>             </field>
> __________________________________________________________________
>
> Everything else is as default. What am I doing wrong? I spent the whole
> day trying to figure this out but i'm not getting anywhere...
>
> thanks,
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message