[ 
https://issues.apache.org/struts/browse/WW-2485?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Zahid Nazir updated WW-2485:
----------------------------

    Description: 
Hi,
Validation (client or server side) doesn't occur and no message is thrown back 
when annotating setters (I checked getter too but to no affect),see below

//      @StringLengthFieldValidator(message="Default message", 
key="errors.required.first", shortCircuit=true, trim=true, minLength="1", 
maxLength="35")
//      @RequiredFieldValidator(message = "You must enter a string value for 
first...", key="errors.required.last", shortCircuit=false)
        @RequiredStringValidator(message = "First", 
key="errors.required.first", shortCircuit=true, trim=true)  
        public void setFirst(String first) {
                this.first = first;
        }

Validation does get invoked for @RequiredStringValidator but then shortCircuit 
doesn't seem to work. 

Here is the class declaration

@Validation()
public class ProfileSearch extends ActionSupport {

// getter
//      @StringLengthFieldValidator(message="Default message", 
key="errors.required.last", shortCircuit=true, trim=true, minLength="1", 
maxLength="35") 
//      @RequiredFieldValidator(message = "You must enter a string value for 
last...", key="errors.required.last", shortCircuit=true)
        @RequiredStringValidator(message = "Last", key="errors.required.last", 
shortCircuit=true, trim=true)
        public String getLast() {
                return last;
        }

// Setter
//      @StringLengthFieldValidator(message="Default message", 
key="errors.required.last", shortCircuit=true, trim=true, minLength="1", 
maxLength="35")
//      @RequiredFieldValidator(message = "You must enter a string value for 
last...", key="errors.required.last", shortCircuit=false)
        @RequiredStringValidator(message = "Last", key="errors.required.last", 
shortCircuit=true, trim=true)    
        public void setLast(String last) {
                this.last = last;
        }

and jsp snippet

                <s:form action="addressSearch!search" method="post" 
validate="false">
                        <s:textfield name="first" value="%{first}" 
label="%{getText('label.first')}" labelposition="left" tabindex="1" 
maxlength="35" required="true" />
                        <s:textfield name="last" value="%{last}" 
label="%{getText('label.last')}" labelposition="left" tabindex="2" 
maxlength="35" required="true"/>

I also used ModelDriven validation using annotations and behavior is same. 
Adding namespace attribute to form element and in struts.xml also doesn't help, 
neither do changing attribute validate="true". I am not declaring any 
interceptors in struts.xml and am extending my package from struts-default.

Thanks for your help.




  was:
Validation (client or server side) doesn't occur and no message is thrown back 
when annotating setters (I checked getter too but to no affect),see below

//      @StringLengthFieldValidator(message="Default message", 
key="errors.required.first", shortCircuit=true, trim=true, minLength="1", 
maxLength="35")
//      @RequiredFieldValidator(message = "You must enter a string value for 
first...", key="errors.required.last", shortCircuit=false)
        @RequiredStringValidator(message = "First", 
key="errors.required.first", shortCircuit=true, trim=true)  
        public void setFirst(String first) {
                this.first = first;
        }

Validation does get invoked for @RequiredStringValidator but then shortCircuit 
doesn't seem to work. 

Here is the class declaration

@Validation()
public class ProfileSearch extends ActionSupport {

// getter
//      @StringLengthFieldValidator(message="Default message", 
key="errors.required.last", shortCircuit=true, trim=true, minLength="1", 
maxLength="35") 
//      @RequiredFieldValidator(message = "You must enter a string value for 
last...", key="errors.required.last", shortCircuit=true)
        @RequiredStringValidator(message = "Last", key="errors.required.last", 
shortCircuit=true, trim=true)
        public String getLast() {
                return last;
        }

// Setter
//      @StringLengthFieldValidator(message="Default message", 
key="errors.required.last", shortCircuit=true, trim=true, minLength="1", 
maxLength="35")
//      @RequiredFieldValidator(message = "You must enter a string value for 
last...", key="errors.required.last", shortCircuit=false)
        @RequiredStringValidator(message = "Last", key="errors.required.last", 
shortCircuit=true, trim=true)    
        public void setLast(String last) {
                this.last = last;
        }

and jsp snippet

                <s:form action="addressSearch!search" method="post" 
validate="false">
                        <s:textfield name="first" value="%{first}" 
label="%{getText('label.first')}" labelposition="left" tabindex="1" 
maxlength="35" required="true" />
                        <s:textfield name="last" value="%{last}" 
label="%{getText('label.last')}" labelposition="left" tabindex="2" 
maxlength="35" required="true"/>

I also used ModelDriven validation using annotations and behavior is same. 
Adding namespace attribute to form element and in struts.xml also doesn't help, 
neither do changing attribute validate="true". I am not declaring any 
interceptors in struts.xml and am extending my package from struts-default.

Thanks.





> Annotation validations (@StringFieldValidator, @StringLengthFieldValidator) 
> doesn't work while @RequiredStringValidator doesn't do shortcircuiting
> --------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-2485
>                 URL: https://issues.apache.org/struts/browse/WW-2485
>             Project: Struts 2
>          Issue Type: Bug
>          Components: XML Validators
>    Affects Versions: 2.0.11
>         Environment: Windows XP SP2, Struts 2.0.11, Jetty 6.0.1
>            Reporter: Zahid Nazir
>
> Hi,
> Validation (client or server side) doesn't occur and no message is thrown 
> back when annotating setters (I checked getter too but to no affect),see below
> //    @StringLengthFieldValidator(message="Default message", 
> key="errors.required.first", shortCircuit=true, trim=true, minLength="1", 
> maxLength="35")
> //    @RequiredFieldValidator(message = "You must enter a string value for 
> first...", key="errors.required.last", shortCircuit=false)
>       @RequiredStringValidator(message = "First", 
> key="errors.required.first", shortCircuit=true, trim=true)  
>       public void setFirst(String first) {
>               this.first = first;
>       }
> Validation does get invoked for @RequiredStringValidator but then 
> shortCircuit doesn't seem to work. 
> Here is the class declaration
> @Validation()
> public class ProfileSearch extends ActionSupport {
> // getter
> //    @StringLengthFieldValidator(message="Default message", 
> key="errors.required.last", shortCircuit=true, trim=true, minLength="1", 
> maxLength="35") 
> //    @RequiredFieldValidator(message = "You must enter a string value for 
> last...", key="errors.required.last", shortCircuit=true)
>       @RequiredStringValidator(message = "Last", key="errors.required.last", 
> shortCircuit=true, trim=true)
>       public String getLast() {
>               return last;
>       }
> // Setter
> //    @StringLengthFieldValidator(message="Default message", 
> key="errors.required.last", shortCircuit=true, trim=true, minLength="1", 
> maxLength="35")
> //    @RequiredFieldValidator(message = "You must enter a string value for 
> last...", key="errors.required.last", shortCircuit=false)
>       @RequiredStringValidator(message = "Last", key="errors.required.last", 
> shortCircuit=true, trim=true)    
>       public void setLast(String last) {
>               this.last = last;
>       }
> and jsp snippet
>               <s:form action="addressSearch!search" method="post" 
> validate="false">
>                       <s:textfield name="first" value="%{first}" 
> label="%{getText('label.first')}" labelposition="left" tabindex="1" 
> maxlength="35" required="true" />
>                       <s:textfield name="last" value="%{last}" 
> label="%{getText('label.last')}" labelposition="left" tabindex="2" 
> maxlength="35" required="true"/>
> I also used ModelDriven validation using annotations and behavior is same. 
> Adding namespace attribute to form element and in struts.xml also doesn't 
> help, neither do changing attribute validate="true". I am not declaring any 
> interceptors in struts.xml and am extending my package from struts-default.
> Thanks for your help.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to