You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Vladimir Limansky (JIRA)" <ji...@apache.org> on 2009/03/20 14:12:02 UTC

[jira] Commented: (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:comment-tabpanel&focusedCommentId=45758#action_45758 ] 

Vladimir Limansky commented on WW-2609:
---------------------------------------

James,
I added the required changes.
Take a look at 
https://issues.apache.org/struts/browse/WW-3035 (server side)
https://issues.apache.org/struts/browse/WW-3036 (client side)
they should be patched all together.
Thanks,
Vladimir

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