Full answer from CC:
⏺ Based on my search of the Struts codebase, I found exactly how
action aliases with slashes are handled!
Answer for Your Specific Case
For your action configuration:
<action name="a/b/myaction.validate"
class="myPath.MyAction"
method="create">
The validation file name should be:
MyAction-a-b-myaction.validate-validation.xml
File location: Place it in src/main/resources/myPath/ (following
your package structure)
The Key Rule
When using action aliases (the name attribute), slashes are replaced
with hyphens in the validation file name:
Pattern:
ClassName-{action-name-with-slashes-replaced-by-hyphens}-validation.xml
How It Works
The validation file resolution code in
AnnotationActionValidatorManager.java:68-71 shows:
protected List<ValidatorConfig> buildAliasValidatorConfigs(Class
aClass, String context, boolean checkFile) {
String fileName = aClass.getName().replace('.', '/') + "-" +
context.replace('/', '-') + VALIDATION_CONFIG_SUFFIX;
return loadFile(fileName, aClass, checkFile);
}
Notice: context.replace('/', '-') - this converts
a/b/myaction.validate to a-b-myaction.validate
Complete Example
For clarity, your full setup should be:
struts.xml:
<action name="a/b/myaction.validate"
class="myPath.MyAction"
method="create">
<result name="input" type="tiles">mytiles</result>
<result name="success" type="tiles">mytiles</result>
</action>
Validation files:
- For all methods: src/main/resources/myPath/MyAction-validation.xml
- For this specific alias:
src/main/resources/myPath/MyAction-a-b-myaction.validate-validation.xml
The alias-specific validation will only apply when the action is
invoked via the a/b/myaction.validate URL pattern.
Cheers
Łukasz
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]