You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Jeromy Evans (JIRA)" <ji...@apache.org> on 2008/04/22 07:31:05 UTC

[jira] Updated: (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 ]

Jeromy Evans updated WW-2609:
-----------------------------

    Assignee:     (was: Jeromy Evans)

Thanks Vladimir.

Please don't automatically assign to a developer as we use that to indicate that a developer *is currently working on* an issue.  

I agree, utils.js should search for a containing element created by s:actionerrors (by Id perhaps) and insert the values.  I've never actually used this Struts2 feature myself though. 


> 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
>
> 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.