• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Struts validator framework, please help

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
did you set validate="true" in your ActionMapping?
 
jay denzel
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I did that.
 
dennis yarborough
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
It's a beautiful day in this neighborhood - Fred Rogers. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic