Re: Validation using Struts2-spring

2020-06-04 Thread M Huzaifah
Dear All,

i am sorry, is my bad. the validation are running well. i am trying to do show 
the message error in action, but in this code the message going to the field 
with parameter named “parameterString1” and i change requiredFiled validation 
to requiredString validation in parameter Validations Annotation.

Thank You All

> On 4 Jun 2020, at 12.00, M Huzaifah  wrote:
> 
> Hii Guys,
> 
> i’am stuck with Validation in Struts2 using struts2-spring plugin. 
> struts version : 2.5.22
> spring version : 5.2.1.RELEASE
> 
> my validators.xml in classpath:
> 
> 
>  "-//Apache Struts//XWork Validator Definition 1.0//EN"
> "http://struts.apache.org/dtds/xwork-validator-definition-1.0.dtd 
> ">
> 
>  class="com.opensymphony.xwork2.validator.validators.RequiredFieldValidator"/>
>  class="com.opensymphony.xwork2.validator.validators.RequiredStringValidator"/>
>  class="com.opensymphony.xwork2.validator.validators.ConversionErrorFieldValidator"/>
> 
> 
> 
> my struts.xml config form constant Struts-spring:
> 
> 
> 
> 
> 
> 
> 
> my validation method using Annotation
> 
> 
>   //validation
>   @Validations( requiredFields = {
>   @RequiredFieldValidator(type = ValidatorType.SIMPLE, 
> fieldName = "parameterString1", message = "You must enter a value for field.")
>   }
>   )
>   @Action(value = "testingValidation", results = {
>   @Result(name = "success", location = 
> "/pages/blank.jsp"),
>   @Result(name = "input", location = "/pages/blank.jsp"),
>   @Result(name = "error", location = "/pages/blank.jsp") 
> },
>   interceptorRefs = {
>   @InterceptorRef("validation")
>   })
>   public String testingValidation() {
>   List a = new ArrayList();
>   a.add("salah field");
>   setActionMessages(a);
>   return SUCCESS;
>   }
> 
> when i hit the URL http://localhost:8080/baseapp/example/testingValidation 
> (without parameter) 
> it does’t show my error message, the error should shown using 
>  tag in JSP.
> 
> when i trace the log, here i found:
> 
> 
> [http-nio-8080-exec-6] DEBUG 
> com.opensymphony.xwork2.validator.ValidationInterceptor - Validating 
> /example/testingValidation with method testingValidation.
> [http-nio-8080-exec-6] TRACE 
> org.springframework.beans.factory.support.DefaultListableBeanFactory - Not 
> autowiring property 'textProviderFactory' of bean 
> 'com.opensymphony.xwork2.validator.validators.RequiredFieldValidator' by 
> name: no matching bean found
> [http-nio-8080-exec-6] TRACE 
> org.springframework.beans.factory.support.DefaultListableBeanFactory - Not 
> autowiring property 'validatorContext' of bean 
> 'com.opensymphony.xwork2.validator.validators.RequiredFieldValidator' by 
> name: no matching bean found
> [http-nio-8080-exec-6] TRACE 
> org.springframework.beans.factory.support.DefaultListableBeanFactory - Not 
> autowiring property 'valueStack' of bean 
> 'com.opensymphony.xwork2.validator.validators.RequiredFieldValidator' by 
> name: no matching bean found
> 
> the spring nt autowiring validation.
> 
> 
> 
> 
> 
> 
> 



Validation using Struts2-spring

2020-06-03 Thread M Huzaifah
Hii Guys,

i’am stuck with Validation in Struts2 using struts2-spring plugin. 
struts version : 2.5.22
spring version : 5.2.1.RELEASE

my validators.xml in classpath:


http://struts.apache.org/dtds/xwork-validator-definition-1.0.dtd";>







my struts.xml config form constant Struts-spring:







my validation method using Annotation


//validation
@Validations( requiredFields = {
@RequiredFieldValidator(type = ValidatorType.SIMPLE, 
fieldName = "parameterString1", message = "You must enter a value for field.")
}
)
@Action(value = "testingValidation", results = {
@Result(name = "success", location = 
"/pages/blank.jsp"),
@Result(name = "input", location = "/pages/blank.jsp"),
@Result(name = "error", location = "/pages/blank.jsp") 
},
interceptorRefs = {
@InterceptorRef("validation")
})
public String testingValidation() {
List a = new ArrayList();
a.add("salah field");
setActionMessages(a);
return SUCCESS;
}

when i hit the URL http://localhost:8080/baseapp/example/testingValidation 
(without parameter) it 
does’t show my error message, the error should shown using  tag 
in JSP.

when i trace the log, here i found:


[http-nio-8080-exec-6] DEBUG 
com.opensymphony.xwork2.validator.ValidationInterceptor - Validating 
/example/testingValidation with method testingValidation.
[http-nio-8080-exec-6] TRACE 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Not 
autowiring property 'textProviderFactory' of bean 
'com.opensymphony.xwork2.validator.validators.RequiredFieldValidator' by name: 
no matching bean found
[http-nio-8080-exec-6] TRACE 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Not 
autowiring property 'validatorContext' of bean 
'com.opensymphony.xwork2.validator.validators.RequiredFieldValidator' by name: 
no matching bean found
[http-nio-8080-exec-6] TRACE 
org.springframework.beans.factory.support.DefaultListableBeanFactory - Not 
autowiring property 'valueStack' of bean 
'com.opensymphony.xwork2.validator.validators.RequiredFieldValidator' by name: 
no matching bean found

the spring nt autowiring validation.