Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Validator question Struts 1.2.9

Dilip Ladhani

2007-03-21

Replies:

I have gotten the validator to work in may of my projects, but I am
stuck on this one and was wondering if someone can help.
I have a MessageResources.properties under WEB-INF/classes which
contains all the messages.
In my struts-config I have the following line
<message-resources key="messages" parameter="MessageResources" />
Here is my validation.xml
    <form name="/showConfirmCompletedCourses">
       <field
          property="selectedCategory"
          depends="required">
            <arg key="label.Category"/>
       </field>
       <field
          property="startDate"
          depends="required,date">
            <arg key="label.StartDate"/>
               <var>
               <var-name>datePattern</var-name>
               <var-value>MM/dd/yyyy</var-value>
           </var>
       </field>
    </form>
I also tried putting <arg bundle="messages" key="label.Category"/>
I always get an exception when I validate. I call the form.validate
from my action class, I always get the following exception

2007-03-21 12:41:36,437] [location -
org.apache.commons.validator.ValidatorAction.executeValidationMethod (ValidatorAction.java:578)]
....Unhandled exception thrown during validation: No message resources
found for bundle: org.apache.struts.action.MESSAGE
java.lang.NullPointerException: No message resources found for bundle:
org.apache.struts.action.MESSAGE
 at org.apache.struts.validator.Resources.getMessageResources (Resources.java:140)
 at org.apache.struts.validator.Resources.getActionMessage (Resources.java:349)
 at org.apache.struts.validator.FieldChecks.validateRequired (FieldChecks.java:94)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke (Method.java:585)

thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.