aspose file tools*
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 Soft Skills this week in the Jobs Discussion 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2: client side repeated validation error messages