This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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

thirumal raps
Greenhorn

Joined: Apr 24, 2009
Posts: 3
I am using struts2 addErrors in javascript to show action errors in my jsp

my javascript sample code:

for (i = 0; i < chk.length; i++)
{
if(chk[i].checked == true)
{
unitQty = document.forms[0].elements["qty"][i].value;
if(qty == ''){
field = document.forms[0].elements["qty"][i];
addError(field, "Quantity is required");
errors = true;
}

when I click on submit it shows the error message "Quantity is required, but when I click it again it shows the new error message without clearing the last one

even through i am clearing error messages in my javascript code with
form = document.getElementById("User");
clearErrorMessages(form);
clearErrorLabels(form);

can anybody help me please

thanks
Thirumal

thirumal raps
Greenhorn

Joined: Apr 24, 2009
Posts: 3
i found the problem

i have added this code in validation.js so that i can clear the multiple error messages in table rows

function clearErrorMessages(form) {

var rows = form.getElementsByTagName("tr");
if (rows == null){
return;
}

for(var i = 0; i < rows.length; i++) {
var r1 = rows[i];
if (r1.getAttribute("errorFor")) {
rows[i].parentNode.removeChild(rows[i]);
}
}
}

thanks
thirumal
 
jQuery in Action, 2nd edition
 
subject: Struts2: client side repeated validation error messages
 
Similar Threads
Struts2 validation problem
inconsistent ajax calls to servlet functions
Struts2 & validation [SOLVED]
Struts2 Validation problem
Validating s:select and s:checkbox with struts2 validator