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

Johannes Geppert updated WW-3395:
---------------------------------

    Attachment: utils.js

following changes working fine in IE7 and Firefox 3.6

StrutsUtils.errorLists = [];

// shows validation errors using functions from xhtml/validation.js
// or css_xhtml/validation.js
StrutsUtils.showValidationErrors = function(form, errors) {
        StrutsUtils.clearValidationErrors(form, errors);

        //Clear previous global error messages
        if(StrutsUtils.errorLists[form] && StrutsUtils.errorLists[form] !== 
null) {
                form.parentNode.removeChild(StrutsUtils.errorLists[form]);
                StrutsUtils.errorLists[form] = null;
        }
        
        if (errors.errors) {
                var errorList = document.createElement("ul");
                errorList.setAttribute("class", "errorMessage");
                errorList.setAttribute("className", "errorMessage"); // ie hack 
cause ie does not support setAttribute

                for ( var l = 0; l < errors.errors.length; l++) {
                        var item = document.createElement("li");
                        var itemText = 
document.createTextNode(errors.errors[l]);
                        item.appendChild(itemText);

                        errorList.appendChild(item);
                }
                
                form.parentNode.insertBefore(errorList, form);
                StrutsUtils.errorLists[form] = errorList;
        }

        var firstNode = StrutsUtils.firstElement(form);
        var xhtml = firstNode.tagName.toLowerCase() == "table";
        if (errors.fieldErrors) {
                for ( var fieldName in errors.fieldErrors) {
                        if (fieldName) {
                                for ( var i = 0; i < 
errors.fieldErrors[fieldName].length; i++) {
                                        if (xhtml) {
                                                
addErrorXHTML(form.elements[fieldName], errors.fieldErrors[fieldName][i]);
                                        }
                                        else {
                                                
addErrorCSS(form.elements[fieldName], errors.fieldErrors[fieldName][i]);
                                        }
                                }
                        }
                }
        }
};


> Client Validation don't display Global Messages
> -----------------------------------------------
>
>                 Key: WW-3395
>                 URL: https://issues.apache.org/jira/browse/WW-3395
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 2.1.8.1
>            Reporter: Johannes Geppert
>            Priority: Minor
>         Attachments: utils.js
>
>
> When I define a Validation like this:
> @Validations(requiredStrings = {
>     @RequiredStringValidator(fieldName = "loginuser", type = 
> ValidatorType.FIELD, message = "Login User is required"), 
>     @RequiredStringValidator(fieldName = "loginpassword", type = 
> ValidatorType.FIELD, message = "Password is required")
> }, expressions = {
>   @ExpressionValidator(expression = "loginpassword.trim().equals('test') == 
> true", message = "Password must be test."),
> })
> The Form with XHTML Theme only display the RequiredString Messages but not 
> the Expression Message.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to