struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JOSE L MARTINEZ-AVIAL <jlm...@gmail.com>
Subject Validation using annotations with two execute methods are applied always
Date Thu, 17 Dec 2015 22:28:57 GMT
Hello,
     I'm using Struts 2.3.24.1. I have an action that has two execute
methods, and it is used by two actions, as follows:

        <action name="CreateUserForClient"
class="com.xxx.EasyEnrollmentCreateClient" method="createUserForClient">
        <action name="CreateUserForParty"
class="com.xxx.EasyEnrollmentCreateClient" method="createUserForParty">


Each method has its own validations, defined by annotations at the method
level.

    @Validations(requiredStrings = {
            @RequiredStringValidator(fieldName="idLanguage", key =
"validation-error.mandatory", messageParams={"getText('idLanguage')"}),
            @RequiredStringValidator(fieldName="idCompany", key =
"validation-error.mandatory", messageParams={"getText('idCompany')"}),
            @RequiredStringValidator(fieldName="idParty", key =
"validation-error.mandatory", messageParams={"getText('idParty')"})})
    public String createUserForParty() throws Exception {



    @Validations(requiredStrings = {
            @RequiredStringValidator(fieldName="idLanguage", key =
"validation-error.mandatory", messageParams={"getText('idLanguage')"}),
            @RequiredStringValidator(fieldName="idCompany", key =
"validation-error.mandatory", messageParams={"getText('idCompany')"}),
            @RequiredStringValidator(fieldName="idCustomer", key =
"validation-error.mandatory", messageParams={"getText('idCustomer')"})})
    public String createUserForClient() throws Exception {


The issue is that both sets of validations are always executed, no matter
which action has been called. And I see in the response that when
idLanguage or idCompany are missing, the error appears twice, since it is
requited in both actions.

What am I doing wrong?

Regards

JL

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message