Two Laptop Bag*
The moose likes Struts and the fly likes Struts2: client side repeated validation error messages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2: client side repeated validation error messages" Watch "Struts2: client side repeated validation error messages" New topic
Author

Struts2: client side repeated validation error messages

Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
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?


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
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

Joined: Nov 27, 2006
Posts: 423

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

Joined: May 14, 2007
Posts: 1
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

Joined: Jun 08, 2008
Posts: 2
What if i want it to be singleton? how do i reset the error list?
Angel Ricardo de Dios Ramirez
Greenhorn

Joined: Dec 19, 2008
Posts: 1
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

Joined: Sep 29, 2008
Posts: 12617

Please start new threads for new questions.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2: client side repeated validation error messages