Action Errors are not supported by  AJAX validation
---------------------------------------------------

                 Key: WW-2609
                 URL: https://issues.apache.org/struts/browse/WW-2609
             Project: Struts 2
          Issue Type: Bug
          Components: XML Validators
    Affects Versions: 2.1.0
         Environment: struts2-core-2.1.0.jar struts2-dojo-plugin-2.1.0.jar 
            Reporter: Vladimir Limansky
            Assignee: Jeromy Evans


Ajax validation provides support on the JAVASCRIPT CLIENT only for field errors 
and there's no place where I could put action errors.
Consider my configuration:
1. here is my CalendarAction-validation.xml

<validators>
  <field name="calendarEventDecorator.title">
      <field-validator type="requiredstring">
          <message key="calendar:TitleIsRequired"/>
      </field-validator>
  </field>
  
  <validator type="eventDatesValidator">
      <message key="calendar:EndDateAfterStartDate"/>
  </validator>
<validators>

2. Here is a piece of my custom validator class:

if (startDate.after(endDate)) {
        addActionError(actionSupport);
}

3. JSON data I got on the client from JSONValidationInterceptor:

/* { "errors":["Event end date should be after start date"],"fieldErrors": 
{"calendarEventDecorator.title":["Event title is required"]}} */

4. Let's look at the utils.js (struts2-core-2.1.0.jar)


StrutsUtils.showValidationErrors = function(form, errors) {
  StrutsUtils.clearValidationErrors(form, errors);

  var firstNode = StrutsUtils.firstElement(form);
  var xhtml = firstNode.tagName.toLowerCase() == "table";  
  if(errors.fieldErrors) {
    for(var fieldName in errors.fieldErrors) {
      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]);
        }  
      }
    }
  }
};

This method adds only fields errors. And there's no one word about action 
errors!

I suppose you to create smth like <sx:actionerrors /> tag (or extend existing 
s:actionerrors tag) to check whether JSON data just returned to the client 
contains field errors




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

Reply via email to