[
https://issues.apache.org/struts/browse/WW-2050?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Lukasz Racon updated WW-2050:
-----------------------------
Attachment: validation2.js
A couple more comments (beside great job):
1) previous one works well, except it ignores validation that is done in
DefaultWorkflowInterceptor (Validateable interface, validateXXX methods).
IMHO, all validation should be in one place and DefaultWorkflowInterceptor
should only decide what to show (result or input page). This way JSON
validatior could have all the errors and could change the flow. (Note that it
may break some apps.)
2) validation.js breaks on radio buttons:
utils.js/StrutsUtils.showValidationErrors provides addErrorXXX a form element
(errors.fieldErrors[fieldName]) - in case of radio buttons (checkboxes) this
returns an array of fields; Array of fields is not a dom node and doesn't have
a parent node - this fails within addErrorCSS;
3) validation.js/addErrorCSS depends too much on the layout
- form field's second parent must be 'wwgrp_'; So if you use custom template it
will break; In attached file I am iterating over parent elements, and looking
for one that has classname eq. to 'wwgrp'.
3) focusing on the first field that has error - it doesn't look like it is
done. I overridden StrutsUtils.showValidationErrors - addErrorCSS stores the
closest to the top of the page field position then focuses on it.
I am using attached validation2.js as a replacement of css_html/validation.js -
it works well for me, although I cannot guarantee that it will work with all
scenarios:)
Some of the stuff within could be applied to more general utilsjs/StrutsUtil
javascript class, so it would work for xhtml theme as well.
> Separate JSONValidationInterceptor from AnnotationValidationInterceptor
> -----------------------------------------------------------------------
>
> Key: WW-2050
> URL: https://issues.apache.org/struts/browse/WW-2050
> Project: Struts 2
> Issue Type: Improvement
> Components: Interceptors
> Affects Versions: 2.1.0
> Reporter: Lukasz Racon
> Assignee: Musachy Barroso
> Priority: Minor
> Fix For: 2.1.0
>
> Attachments: jsonvalidator.diff, validation2.js
>
>
> Since JSONValidationInterceptor extends AnnotationValidationInterceptor it
> should behave exactly as AnnotationValidationInterceptor does.
> Here are the problems:
> - JSONValidationInterceptor ignores @SkipValidation
> - it always performs jason validation. You have to have separate stacks for
> different validation strategies. IMHO as a replacement it should as default
> let the workflow/annotationWorkflow controller to decide what to do.
> - JSON validation should be triggered by a request parameter (for example set
> by the sx:submit tag, or to be precise by Bind widget)
> Proposed solution:
> JSONValidationInterceptor should be an interceptor (not a validating one). It
> should be positioned in the stack after the 'validation' and before
> 'workflow'. This way its sole purpose would be to check for request param
> trigger and action that has errors and return errors as json. Other
> interceptors will be responsible for validation and setting the errors on the
> action. This setup would allow JSON validation to coexist with old submit
> form validation - meaning you would have one stack for both.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.