You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dilip Ladhani <di...@gmail.com> on 2007/03/21 17:48:12 UTC

Validator question Struts 1.2.9

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@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Validator question Struts 1.2.9

Posted by Dilip Ladhani <di...@gmail.com>.
Thanks, I figured it out. I made sure this was by default bundle.

On 3/21/07, Niall Pemberton <ni...@gmail.com> wrote:
> On 3/21/07, Dilip Ladhani <di...@gmail.com> wrote:
> > 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
>
> If you're not using the "default" bundle then you need to specify the
> bundle for all the messages as well - so you would have to add <msg>
> elements for both the "required" and "date" validator in the above
> example (with the "bundle" attribute specified).
>
> Niall
>
> > 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@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: Validator question Struts 1.2.9

Posted by Niall Pemberton <ni...@gmail.com>.
On 3/21/07, Dilip Ladhani <di...@gmail.com> wrote:
> 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

If you're not using the "default" bundle then you need to specify the
bundle for all the messages as well - so you would have to add <msg>
elements for both the "required" and "date" validator in the above
example (with the "bundle" attribute specified).

Niall

> 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@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: Validator question Struts 1.2.9

Posted by Niall Pemberton <ni...@gmail.com>.
On 3/21/07, Dilip Ladhani <di...@gmail.com> wrote:
> Thanks for the reply.
> However, after doing that I get the error
> ....Unhandled exception thrown during validation: No message resources
> found for bundle: messages
> java.lang.NullPointerException: No message resources found for bundle: messages

OK after making it the default - did you remove the bundle="messages"
from your validation.xml?

Also take a look at the "bundles" example in the validator part of the
struts-examples webapp shipped with Struts 1.2.9

Niall

> Also, on various jsps, I would have to, I would have to remove
> bundle="messages", for eg
> <bean:message bundle="messages" key="heading.viewHistory" />
> This I can do, however, I still get the above error
>
> On 3/21/07, Nuwan Chandrasoma <my...@gmail.com> wrote:
> > make your message resource as the defautl one, dont put any key just add the
> > entry
> > <message-resources  parameter="MessageResources" />
> >
> > in struts-config and see.,
> >
> > Thanks & Regards,
> >
> > Nuwan.
> >
> >
> >
> > ----- Original Message -----
> > From: "Dilip Ladhani" <di...@gmail.com>
> > To: <us...@struts.apache.org>
> > Sent: Wednesday, March 21, 2007 4:48 PM
> > Subject: Validator question Struts 1.2.9
> >
> >
> > >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@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: Validator question Struts 1.2.9

Posted by Dilip Ladhani <di...@gmail.com>.
Thanks for the reply.
However, after doing that I get the error
....Unhandled exception thrown during validation: No message resources
found for bundle: messages
java.lang.NullPointerException: No message resources found for bundle: messages

Also, on various jsps, I would have to, I would have to remove
bundle="messages", for eg
<bean:message bundle="messages" key="heading.viewHistory" />
This I can do, however, I still get the above error

On 3/21/07, Nuwan Chandrasoma <my...@gmail.com> wrote:
> make your message resource as the defautl one, dont put any key just add the
> entry
> <message-resources  parameter="MessageResources" />
>
> in struts-config and see.,
>
> Thanks & Regards,
>
> Nuwan.
>
>
>
> ----- Original Message -----
> From: "Dilip Ladhani" <di...@gmail.com>
> To: <us...@struts.apache.org>
> Sent: Wednesday, March 21, 2007 4:48 PM
> Subject: Validator question Struts 1.2.9
>
>
> >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@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: Validator question Struts 1.2.9

Posted by Nuwan Chandrasoma <my...@gmail.com>.
make your message resource as the defautl one, dont put any key just add the 
entry
<message-resources  parameter="MessageResources" />

in struts-config and see.,

Thanks & Regards,

Nuwan.



----- Original Message ----- 
From: "Dilip Ladhani" <di...@gmail.com>
To: <us...@struts.apache.org>
Sent: Wednesday, March 21, 2007 4:48 PM
Subject: Validator question Struts 1.2.9


>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@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


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