You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (JIRA)" <ji...@apache.org> on 2010/03/26 09:24:27 UTC

[jira] Resolved: (WW-3295) Display of Ajax-Validation-Errors may fail on Internet Explorer

     [ https://issues.apache.org/jira/browse/WW-3295?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart resolved WW-3295.
-------------------------------

    Resolution: Fixed
      Assignee: Lukasz Lenart

Patch applied, thanks!

> Display of Ajax-Validation-Errors may fail on Internet Explorer
> ---------------------------------------------------------------
>
>                 Key: WW-3295
>                 URL: https://issues.apache.org/jira/browse/WW-3295
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 2.1.6
>            Reporter: Wolfgang Schröder
>            Assignee: Lukasz Lenart
>             Fix For: 2.2.0
>
>
> I'm using prototype.js together with the ajax-validation-interceptor and the "built-in" StrutsUtils-JavaScript. The validation itself works perfect for both, Firefox and IE. When it comes to displaying the errormessages per field, I'm using the "built-in" JavaScript-Utilities /struts/utils.js and /struts/css_xhtml/validation.js
> When the ajax-validation returns I'm calling StrutsUtils.showValidationErrors(form, errorsObject); which fails on IE with a JavaScript-Alert (one per validation/fielderror) showing "An exception occurred: Error. Error message: Illegal argument but not on Firefox.
> I drilled into the problem and found, that the variable 'firstCtrNode' is undefined (in both, IE and Firefox). This causes a problem in the call 'enclosingDiv.insertBefore(errorDiv, firstCtrNode);'
> IE and Firefox are showing different behaviour. Firefox always insists on a two arg call, even if the second arg is null. IE throws an exception when the second arg is null and only accepts a call with one arg.
> Code from /struts/css_xhtml/validation.js, from Line 94 on:
>         var firstCtrNode = findWWCtrlNode(enclosingDiv); // either wwctrl_ or wwlbl_
>         
>         var error = document.createTextNode(errorText);
>         var errorDiv = document.createElement("div");
>         errorDiv.setAttribute("class", "errorMessage");//standard way.. works for ie mozilla
>         errorDiv.setAttribute("className", "errorMessage");//ie hack cause ie does not support setAttribute
>         errorDiv.setAttribute("errorFor", elem.id);
>         errorDiv.appendChild(error);
>         enclosingDiv.insertBefore(errorDiv, firstCtrNode); // <---- This line fails on IE
> My bugfix/workaround is:
>         if(!firstCtrNode && navigator.appName == 'Microsoft Internet Explorer')
>           enclosingDiv.insertBefore(errorDiv);
>         else
>           enclosingDiv.insertBefore(errorDiv, firstCtrNode);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.