[
https://issues.apache.org/struts/browse/WW-3180?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Laurent Mimoun updated WW-3180:
-------------------------------
Description:
Problem
In our pages, we have one form for the entire page because the user must decide
(after a javascript confirmation) to save the data modified in all the block of
the page. But in some case and if the user decide not saving all the modified
page fields, we must only validate fields, the user want to save.
STRUTS ParameterInterceptor and ValidationInterceptor interceptors don't offer
a good solution for this problem : the only solution is to migrate the
validation annotations to declare validation rules in an XML file (but there
will be a lot of code duplication in this case) or coding rules by hand in a
validate method.
In our application, we found this trick but this is not elegant : we added a
new interceptor ValidationFilterInterceptor that calls a method dynamically
actionMethodValidationFilter (if the action method id actionMethod, the
validationFilterInterceptor will call actionMethodValidationFilter) where we
remove the "bad" errors (something like this :
setFieldErrors(filterFieldErrorsOn("data2", getFieldErrors())));
Solution
1. to add a new Annotation @ValidationCase(name="validationCase1") that applies
on the action method
2. to add a new parameter validationCase in all Validation annotation ex :
@RequiredValidator(key = "validation.required", validationCase={"case1"})
3. to take into account in ParameterInterceptor and ValidationInterceptor, this
annotation and new parameter in existing annotations to add
conversion/validation rules only for the annotation linked to the "current"
validation case.
was:
Problem
In our pages, we have one form for the entire page because the user must decide
(after a javascript confirmation) to save the data modified in all the block of
the page. But in some case and if the user decide not saving all the modified
page fields, we must only validate fields, the user want to save.
STRUTS ParameterInterceptor and ValidationInterceptor interceptors don't offer
a good solution for this problem : the only solution is to migrate the
validation annotations to declare validation rules in an XML file (but there
will be a lot of code duplication in this case) or coding rules by hand in a
validate method.
In our application, we found this trick but this is not elegant : we added a
new interceptor ValidationFilterInterceptor that calls a method dynamically (if
the action method id actionMethod, the validationFilterInterceptor will call
actionMethodValidationFilter).
Solution
We propose:
1. to add a new Annotation @ValidationCase(name="validationCase1") that applies
on the action method
2. to add a new parameter validationCase in all Validation annotation ex :
@RequiredValidator(key = "validation.required", validationCase={"case1"})
3. to take into account in ParameterInterceptor and ValidationInterceptor, this
annotation and new parameter in existing annotations to add
conversion/validation rules only for the annotation linked to the "current"
validation case.
> Add the capabilities to activate validation only in some cases
> --------------------------------------------------------------
>
> Key: WW-3180
> URL: https://issues.apache.org/struts/browse/WW-3180
> Project: Struts 2
> Issue Type: New Feature
> Components: "New" API, Core Actions, Core Interceptors, XML
> Validators
> Affects Versions: 2.1.7
> Reporter: Laurent Mimoun
>
> Problem
> In our pages, we have one form for the entire page because the user must
> decide (after a javascript confirmation) to save the data modified in all the
> block of the page. But in some case and if the user decide not saving all the
> modified page fields, we must only validate fields, the user want to save.
> STRUTS ParameterInterceptor and ValidationInterceptor interceptors don't
> offer a good solution for this problem : the only solution is to migrate the
> validation annotations to declare validation rules in an XML file (but there
> will be a lot of code duplication in this case) or coding rules by hand in a
> validate method.
> In our application, we found this trick but this is not elegant : we added a
> new interceptor ValidationFilterInterceptor that calls a method dynamically
> actionMethodValidationFilter (if the action method id actionMethod, the
> validationFilterInterceptor will call actionMethodValidationFilter) where we
> remove the "bad" errors (something like this :
> setFieldErrors(filterFieldErrorsOn("data2", getFieldErrors())));
> Solution
> 1. to add a new Annotation @ValidationCase(name="validationCase1") that
> applies on the action method
> 2. to add a new parameter validationCase in all Validation annotation ex :
> @RequiredValidator(key = "validation.required", validationCase={"case1"})
> 3. to take into account in ParameterInterceptor and ValidationInterceptor,
> this annotation and new parameter in existing annotations to add
> conversion/validation rules only for the annotation linked to the "current"
> validation case.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.