• 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

Struts2: client side repeated validation error messages

 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I enabled the client side validation error in the JSP. When the user enters some wrong/missing information for the 1st time and submits, the client-side validation kicks in and shows the error messages. When the user clicks submit again, the same error messages are repeated. Is there a way to clear the previous error messages before printing the new ones?
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did some checking and found that the client side validation depends on the Javascript file validation.js under each theme. Viewed the source of my JSP and found that the validation Javascript function will actually call the clearErrorMessages(form) and clearErrorLabels(form) functions in validation.js before executing.

It seems that these 2 functions are not doing their job? Tried to add an alert() in each of these functions (end), but still the alert didn't come up.

Does anyone encounter the same issues?
 
Ranch Hand
Posts: 433
Netbeans IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using the spring plugin? If so, make sure that your spring beans are no singletons (by setting in the application-context.xml the value singleton to false, in the bean-tag). Took me also several hours to find this out.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Joachim Rohde!!, i had the same problem with struts 2 and spring plugin for instantiate actions. The problem was:
1. On each validation error, the messages validation is reprinted once more.
2. When there was not error validation, the form not redirect to the action.

But configurating each action like no singletons in the application-context.xml, all works fine.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What if i want it to be singleton? how do i reset the error list?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I'm begining with Struts 2, but I'm having the same problem when trying to do AJAX client side validation.

Config:
-Struts 2.1.6
-Java 5

I added <sx:head /> and <sx:submit validate="true" /> in order to do this.

But just Chengwei Lee, the first time I click on submit it shows the error message, but when I click it again it shows the new error message without clearing the last one.

I've searched on the web but haven't found the solution. Hope you can help me. Thanks in advance.

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please start new threads for new questions.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic