Overriding struts validate method for showing custom error message during FileUpload
@SuppressWarnings("unchecked")
public void validate()
{
List<String> uploadErrors = (List<String>)getActionErrors();
if (getFieldErrors().get("upload") != null)
{
uploadErrors.addAll((List<String>)getFieldErrors().get("upload"));
}
for (String err : uploadErrors)
{
if ( err.startsWith("Enter the Error Message to be overridden"))
{
clearErrorsAndMessages();
addActionError("Enter new error message");
break;
}
}
}
No comments:
Post a Comment