• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts validation not displaying error messages

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've searched on this forum and on Google and I just can't figure out why my validation messages are not showing up when I set it up for automatic validation (i.e. using the ValidatorPlugin and the XML's). If I do manual validation, everything works but I want to use automatic instead. What I want to do is check schedule name is not empty. When I submit my form, it brings me back to the page, leading me to believe that the validation is working, but no error message is displayed.

Here's what I have:

CreateScheduleForm:


struts-config.xml:


validation.xml


my createSchedule.jsp has:


I have a MessageResources.properties file defined in the WEB-INF/classes directory with
errors.required={0} is required.
schedule.name=Schedule name

Note I am using ValidatorActionForm here so that I can map validation to a specific action instead of a form-bean. I have also tried doing it the other way, extending ValidatorForm instead and using the form-bean-name in the validation.xml.

I get no exceptions from Tomcat or logs.

Please let me know if more information is required. Much appreciation and thanks in advanced, I always get amazing help from you guys
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your validation.xml chnage the form name=CreateScheduleForm to this. form name should be the name of the form you defined not the action path.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing jumps out at me. I have never used ValidatorActionForm, but it looks like your usage is correct. Do you always get returned back to the initial page, or just when you enter invalid values? If you remove the form entry from validation.xml do you always go to the next page?

- Brent
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi.
i hope you have used saveErrors() methos in servlet after error.add()
 
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

You are not getting any validation messages correct ? is your ApplicationResources.properties file is place ? The arg0 key
is schedule.name. This key and the message for this should be present in
ApplicationResources.properties file, The message for this key will be picked and it will be inserted into {0} at run time.

[At least this is what i know. May be ot provides yu with some pointers]

Thanks in advance !
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<message-resources parameter="MessageResources"/>

I doubt whether this will work ? Is it compulsory to name your application resources properties file as ApplicationResources.properties ? I think it wont be. In your case the name of the file is MessageResources,
but please verify whether the file is present in proper location. In your case the location is

/WEB-INF/classes/MessageResources.properties

Please let me know !
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<message-resources parameter="MessageResources"/>

I doubt whether this will work ? Is it compulsory to name your application resources properties file as ApplicationResources.properties ? I think it wont be. In your case the name of the file is MessageResources,
but please verify whether the file is present in proper location. In your case the location is

/WEB-INF/classes/MessageResources.properties

Please let me know !
 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<message-resources parameter="MessageResources"/>

I doubt whether this will work ? Is it compulsory to name your application resources properties file as ApplicationResources.properties ? I think it wont be. In your case the name of the file is MessageResources,
but please verify whether the file is present in proper location. In your case the location is

/WEB-INF/classes/MessageResources.properties

Please let me know !
reply
    Bookmark Topic Watch Topic
  • New Topic