Validation XML file names when action name has slashes
------------------------------------------------------
Key: WW-3024
URL: https://issues.apache.org/struts/browse/WW-3024
Project: Struts 2
Issue Type: Bug
Components: XML Validators
Affects Versions: 2.1.6
Environment: struts 2.1.6, Tomcat 6.0, Spring 2.5.6
Reporter: Peter Kelley
I have a generic struts.xml action configuration as follows:
...
<constant name="struts.enable.SlashesInActionNames" value="true"/>
...
<action name="*/*/*" method="{3}"
class="{1}Controller">
<result name="Search">/{1}/search{2}.jsp</result>
<result name="Not Found">/{1}/search{2}.jsp</result>
<result name="List">/{1}/list{2}.jsp</result>
<result name="Show">/{1}/show{2}.jsp</result>
<result name="Edit">/{1}/edit{2}.jsp</result>
<result name="input">/{1}/edit{2}.jsp</result>
</action>
I want to add validation XML for specific contexts by setting up validation.xml
files. Unfortunately the invocation context in this case contains slashes so
that the name of the file that the validation framework is looking for is
invalid. For instance if I was executing the action posting/Posting/save on the
action class PostingController then I want the validation.xml to be named:
PostingController-posting-Posting-save-validation.xml rather
rather than:
PostingController-posting/Posting/save-validation.xml
which is an invalid file name. To achieve this I propose that the following
method defined at line 205 of
com.opensymphony.xwork2.validator.AnnotationActionValidatorManager be changed
from:
private List<ValidatorConfig> buildAliasValidatorConfigs(Class aClass,
String context, boolean checkFile) {
String fileName = aClass.getName().replace('.', '/') + "-" + context +
VALIDATION_CONFIG_SUFFIX;
return loadFile(fileName, aClass, checkFile);
}
to
private List<ValidatorConfig> buildAliasValidatorConfigs(Class aClass,
String context, boolean checkFile) {
String fileName = aClass.getName().replace('.', '/') + "-" +
context.replace('/', '-') + VALIDATION_CONFIG_SUFFIX;
return loadFile(fileName, aClass, checkFile);
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.