File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2: client side repeated validation error messages

 
Chengwei Lee
Ranch Hand
Posts: 884
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Joachim Rohde
Ranch Hand
Posts: 433
Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Isaac Mendoza
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Dinc Ozdemir
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What if i want it to be singleton? how do i reset the error list?
 
Angel Ricardo de Dios Ramirez
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • 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.

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please start new threads for new questions.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic