You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Musachy Barroso (JIRA)" <ji...@apache.org> on 2009/04/18 20:13:06 UTC

[jira] Resolved: (WW-2609) Action Errors are not supported by AJAX validation

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

Musachy Barroso resolved WW-2609.
---------------------------------

    Resolution: Won't Fix

The two mentioned tickets are closed already. I understand the problem, but I am not sure about the solution. The problem is that there is no way for the callback javascript code to know where the use wants to add the action errors. These built in functionality is helpful for a small number of use cases, but in general it is expected that the user will write their own call back to his/her needs. 

> 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: Improvement
>          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
>             Fix For: 2.1.7
>
>
> 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.