Struts validator framework, please help
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi,
I am trying to integrate the validator framework into an existing application, but unfortunatly it does not work and I have no clue why.
I did the following things:
1. Added this to my struts-config file:
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathname" value="/WEB-INF/validator-rules.xml"/>
<set-property property="pathname" value="/WEB-INF/validator.xml"/>
</plug-in>
2. Modified an example form bean to extends ValidatorForm.
3. Added this to my web.xml
<servlet>
<servlet-name>validator</servlet-name>
<servlet-class>org.apache.struts.validator.action.ValidatorServlet</servlet-class>
<init-param>
<param-name>config-rules</param-name>
<param-value>/WEB-INF/validator-rules.xml</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/validator.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
4. Added a validation rule to validator.xml
<form-validation>
<formset>
<form name="bookForm">
<field property="title" depends="required"/>
<field property="pages" depends="required"/>
</form>
</formset>
</form-validation>
Validation is enabled and my reference in struts-config.xml is called "bookForm".
Did I miss anything?
When I submit my form nothing without the required data nothing happens. If I insert a validate method it works great, but without ... ?
Does anyone have an idea what might be the problem?
Thanks in advance.
Greets.
jay
-------
SCJP, SCJD
I am trying to integrate the validator framework into an existing application, but unfortunatly it does not work and I have no clue why.
I did the following things:
1. Added this to my struts-config file:
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathname" value="/WEB-INF/validator-rules.xml"/>
<set-property property="pathname" value="/WEB-INF/validator.xml"/>
</plug-in>
2. Modified an example form bean to extends ValidatorForm.
3. Added this to my web.xml
<servlet>
<servlet-name>validator</servlet-name>
<servlet-class>org.apache.struts.validator.action.ValidatorServlet</servlet-class>
<init-param>
<param-name>config-rules</param-name>
<param-value>/WEB-INF/validator-rules.xml</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/validator.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
4. Added a validation rule to validator.xml
<form-validation>
<formset>
<form name="bookForm">
<field property="title" depends="required"/>
<field property="pages" depends="required"/>
</form>
</formset>
</form-validation>
Validation is enabled and my reference in struts-config.xml is called "bookForm".
Did I miss anything?
When I submit my form nothing without the required data nothing happens. If I insert a validate method it works great, but without ... ?
Does anyone have an idea what might be the problem?
Thanks in advance.
Greets.
jay
-------
SCJP, SCJD
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
did you set validate="true" in your ActionMapping?
jay denzel
Ranch Hand
Posts: 57
dennis yarborough
Greenhorn
Posts: 4
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
It's my understanding that with Struts 1.1 the ValidatorPlugIn replaces the ValidatorServlet. I see in your web.xml your initializing the servlet. In 1.1 the plugin initializes the resources, versus the servlet initializing them.
jay denzel
Ranch Hand
Posts: 57
posted 22 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Problem solved! I checked the log file and found that the ValidatorPlugin was not loaded correct, some classes where missing.
Thanks for your help.
jay
Thanks for your help.
jay
| Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ... The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |






