You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Greg Huber (JIRA)" <ji...@apache.org> on 2013/01/18 16:24:13 UTC
[jira] [Comment Edited] (WW-1967) Dynamic Method Invocation,
validator with ActionName-aliasName-validation.xml files.
[ https://issues.apache.org/jira/browse/WW-1967?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13557252#comment-13557252 ]
Greg Huber edited comment on WW-1967 at 1/18/13 3:23 PM:
---------------------------------------------------------
I have done some debugging on one of my actions:
The class name is EventAdd, the method is save and the action is eventAdd
action:eventAdd!save
In the validation interceptor these are the file names it is looking for in the AnnotationActionValidatorManager class:
UNMODIFIED DefaultActionMapper
java/lang/Object-validation.xml
java/lang/Object-eventAdd-validation.xml
com/opensymphony/xwork2/Action-validation.xml
com/opensymphony/xwork2/Action-eventAdd-validation.xml
com/opensymphony/xwork2/Validateable-validation.xml
com/opensymphony/xwork2/Validateable-eventAdd-validation.xml
com/opensymphony/xwork2/ValidationAware-validation.xml
com/opensymphony/xwork2/ValidationAware-eventAdd-validation.xml
com/opensymphony/xwork2/TextProvider-validation.xml
com/opensymphony/xwork2/TextProvider-eventAdd-validation.xml
com/opensymphony/xwork2/LocaleProvider-validation.xml
com/opensymphony/xwork2/LocaleProvider-eventAdd-validation.xml
java/io/Serializable-validation.xml
java/io/Serializable-eventAdd-validation.xml
com/opensymphony/xwork2/ActionSupport-validation.xml
com/opensymphony/xwork2/ActionSupport-eventAdd-validation.xml
events/ui/struts2/editor/EventBase-validation.xml
events/ui/struts2/editor/EventBase-eventAdd-validation.xml
events/ui/struts2/editor/EventAdd-validation.xml
events/ui/struts2/editor/EventAdd-eventAdd-validation.xml
There is no method checking done for the save method on EventAdd.
These are the file names it is looking for in the AnnotationActionValidatorManager class:
MODIFIED DefaultActionMapper
java/lang/Object-validation.xml
java/lang/Object-eventAdd!save-validation.xml
com/opensymphony/xwork2/Action-validation.xml
com/opensymphony/xwork2/Action-eventAdd!save-validation.xml
com/opensymphony/xwork2/Validateable-validation.xml
com/opensymphony/xwork2/Validateable-eventAdd!save-validation.xml
com/opensymphony/xwork2/ValidationAware-validation.xml
com/opensymphony/xwork2/ValidationAware-eventAdd!save-validation.xml
com/opensymphony/xwork2/TextProvider-validation.xml
com/opensymphony/xwork2/TextProvider-eventAdd!save-validation.xml
com/opensymphony/xwork2/LocaleProvider-validation.xml
com/opensymphony/xwork2/LocaleProvider-eventAdd!save-validation.xml
java/io/Serializable-validation.xml
java/io/Serializable-eventAdd!save-validation.xml
com/opensymphony/xwork2/ActionSupport-validation.xml
com/opensymphony/xwork2/ActionSupport-eventAdd!save-validation.xml
events/ui/struts2/editor/EventBase-validation.xml
events/ui/struts2/editor/EventBase-eventAdd!save-validation.xml
events/ui/struts2/editor/EventAdd-validation.xml
events/ui/struts2/editor/EventAdd-eventAdd!save-validation.xml
Which you can see that it is checking for the save method now.
I guess the question is why does it not use the save method in the unmodified version (first)?
was (Author: gregh99):
I have done some debugging on one of my actions:
The class name is EventAdd, the method is save and the action is eventAdd
action:eventAdd!save
In the validation interceptor these are the file names it is looking for in the AnnotationActionValidatorManager class:
UNMODIFIED DefaultActionMapper
java/lang/Object-validation.xml
java/lang/Object-eventAdd-validation.xml
com/opensymphony/xwork2/Action-validation.xml
com/opensymphony/xwork2/Action-eventAdd-validation.xml
com/opensymphony/xwork2/Validateable-validation.xml
com/opensymphony/xwork2/Validateable-eventAdd-validation.xml
com/opensymphony/xwork2/ValidationAware-validation.xml
com/opensymphony/xwork2/ValidationAware-eventAdd-validation.xml
com/opensymphony/xwork2/TextProvider-validation.xml
com/opensymphony/xwork2/TextProvider-eventAdd-validation.xml
com/opensymphony/xwork2/LocaleProvider-validation.xml
com/opensymphony/xwork2/LocaleProvider-eventAdd-validation.xml
java/io/Serializable-validation.xml
java/io/Serializable-eventAdd-validation.xml
com/opensymphony/xwork2/ActionSupport-validation.xml
com/opensymphony/xwork2/ActionSupport-eventAdd-validation.xml
events/ui/struts2/util/UIActionPreparable-validation.xml
events/ui/struts2/util/UIActionPreparable-eventAdd-validation.xml
events/ui/struts2/util/UISecurityEnforced-validation.xml
events/ui/struts2/util/UISecurityEnforced-eventAdd-validation.xml
events/ui/struts2/util/UIAction-validation.xml
events/ui/struts2/util/UIAction-eventAdd-validation.xml
events/ui/struts2/editor/EventBase-validation.xml
events/ui/struts2/editor/EventBase-eventAdd-validation.xml
events/ui/struts2/editor/EventAdd-validation.xml
events/ui/struts2/editor/EventAdd-eventAdd-validation.xml
There is no method checking done for the save method on EventAdd.
These are the file names it is looking for in the AnnotationActionValidatorManager class:
MODIFIED DefaultActionMapper
java/lang/Object-validation.xml
java/lang/Object-eventAdd!save-validation.xml
com/opensymphony/xwork2/Action-validation.xml
com/opensymphony/xwork2/Action-eventAdd!save-validation.xml
com/opensymphony/xwork2/Validateable-validation.xml
com/opensymphony/xwork2/Validateable-eventAdd!save-validation.xml
com/opensymphony/xwork2/ValidationAware-validation.xml
com/opensymphony/xwork2/ValidationAware-eventAdd!save-validation.xml
com/opensymphony/xwork2/TextProvider-validation.xml
com/opensymphony/xwork2/TextProvider-eventAdd!save-validation.xml
com/opensymphony/xwork2/LocaleProvider-validation.xml
com/opensymphony/xwork2/LocaleProvider-eventAdd!save-validation.xml
java/io/Serializable-validation.xml
java/io/Serializable-eventAdd!save-validation.xml
com/opensymphony/xwork2/ActionSupport-validation.xml
com/opensymphony/xwork2/ActionSupport-eventAdd!save-validation.xml
events/ui/struts2/util/UIActionPreparable-validation.xml
events/ui/struts2/util/UIActionPreparable-eventAdd!save-validation.xml
events/ui/struts2/util/UISecurityEnforced-validation.xml
events/ui/struts2/util/UISecurityEnforced-eventAdd!save-validation.xml
events/ui/struts2/util/UIAction-validation.xml
events/ui/struts2/util/UIAction-eventAdd!save-validation.xml
events/ui/struts2/editor/EventBase-validation.xml
events/ui/struts2/editor/EventBase-eventAdd!save-validation.xml
events/ui/struts2/editor/EventAdd-validation.xml
events/ui/struts2/editor/EventAdd-eventAdd!save-validation.xml
Which you can see that it is checking for the save method now.
I guess the question is why does it not use the save method in the unmodified version (first)?
> Dynamic Method Invocation, validator with ActionName-aliasName-validation.xml files.
> ------------------------------------------------------------------------------------
>
> Key: WW-1967
> URL: https://issues.apache.org/jira/browse/WW-1967
> Project: Struts 2
> Issue Type: Bug
> Components: Core Actions
> Affects Versions: 2.0.6
> Environment: Fedora 4, tomcat
> Reporter: Greg Huber
> Priority: Minor
> Fix For: 2.3.9
>
> Attachments: patch_WW-1967.txt
>
>
> Hello,
> I have been trying to get validation working with dynamic method invocation, using ActionName-aliasName-validation.xml files.
> When the struts.property is set >> struts.enable.DynamicMethodInvocation=true, in the DefaultActionMapper the mapping name is changed by removing !submit from the action eg fieldValidatorsExamples!submit becomes fieldValidatorsExamples. When the validator tries to find FieldValidatorsExampleAction-fieldValidatorsExamples!submit-validator.xml it cannot, as the validator is looking for FieldValidatorsExampleAction-fieldValidatorsExamples-validator.xml. But this is now not linked to a method.
> {code:java}
> if (allowDynamicMethodCalls) {
> // handle "name!method" convention.
> String name = mapping.getName();
> int exclamation = name.lastIndexOf("!");
> if (exclamation != -1) {
> mapping.setName(name.substring(0, exclamation));
> mapping.setMethod(name.substring(exclamation + 1));
> }
> }
> {code}
> With struts.enable.DynamicMethodInvocation=false, validator works but method name is null.
> This line of code is causing the problem mapping.setName(name.substring(0, exclamation));. Without this line seems to work but I am no expert!
> eg:
> {code:xml}
> <action name="fieldValidatorsExamples!*" class="org.apache.struts2.showcase.validation.FieldValidatorsExampleAction" method="{1}" >
> <result name="input" type="dispatcher">/validation/fieldValidatorsExample.jsp</result>
> <result type="dispatcher">/validation/successFieldValidatorsExample.jsp</result>
> </action>
> {code}
> {code:html}
> <s:form action="fieldValidatorsExamples!submit" namespace="/validation" method="POST" theme="xhtml">
> <s:textfield label="Required Validator Field" name="requiredValidatorField" />
> <s:textfield label="Required String Validator Field" name="requiredStringValidatorField" />
> <s:textfield label="Integer Validator Field" name="integerValidatorField" />
> <s:textfield label="Date Validator Field" name="dateValidatorField" />
> <s:textfield label="Email Validator Field" name="emailValidatorField" />
> <s:textfield label="URL Validator Field" name="urlValidatorField" />
> <s:textfield label="String Length Validator Field" name="stringLengthValidatorField" />
> <s:textfield label="Regex Validator Field" name="regexValidatorField"/>
> <s:textfield label="Field Expression Validator Field" name="fieldExpressionValidatorField" />
> <s:submit label="Submit" />
> </s:form>
> {code}
> Cheers Greg
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira