Results 1 to 3 of 3

Thread: initBinder validation error

  1. #1

    Exclamation initBinder validation error

    Hi,

    I am using spring @InitBinder in which I have to register one of the propertyEditor to support Short datatype. I have used CustomNumberEditor but even though am getting an error.

    Am doing in this way like
    binder.registerCustomEditor(Short.class, "birthYear", new CustomNumberEditor(Short.class,true));
    and am getting an error like
    org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBinding Result: 1 errors
    Field error in object 'user' on field 'birthYear': rejected value [dsfs]; codes [typeMismatch.user.birthYear,typeMismatch.birthYear ,typeMismatch.java.lang.Short,typeMismatch]; arguments [org.springframework.context.support.DefaultMessage SourceResolvable: codes [user.birthYear,birthYear]; arguments []; default message [birthYear]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Short' for property 'birthYear'; nested exception is java.lang.NumberFormatException: For input string: "dsfs"]
    at org.springframework.web.method.annotation.ModelAtt ributeMethodProcessor.resolveArgument(ModelAttribu teMethodProcessor.java:110)
    at org.springframework.web.method.support.HandlerMeth odArgumentResolverComposite.resolveArgument(Handle rMethodArgumentResolverComposite.java:74)
    at org.springframework.web.method.support.InvocableHa ndlerMethod.getMethodArgumentValues(InvocableHandl erMethod.java:155)
    at org.springframework.web.method.support.InvocableHa ndlerMethod.invokeForRequest(InvocableHandlerMetho d.java:117)
    at org.springframework.web.servlet.mvc.method.annotat ion.ServletInvocableHandlerMethod.invokeAndHandle( ServletInvocableHandlerMethod.java:96)
    at org.springframework.web.servlet.mvc.method.annotat ion.RequestMappingHandlerAdapter.invokeHandlerMeth od(RequestMappingHandlerAdapter.java:617)
    at org.springframework.web.servlet.mvc.method.annotat ion.RequestMappingHandlerAdapter.handleInternal(Re questMappingHandlerAdapter.java:578)
    at org.springframework.web.servlet.mvc.method.Abstrac tHandlerMethodAdapter.handle(AbstractHandlerMethod Adapter.java:80)
    at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:900)
    at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:827)
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:882)
    at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:789)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
    at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 311)
    at org.springframework.security.web.access.intercept. FilterSecurityInterceptor.invoke(FilterSecurityInt erceptor.java:116)
    at org.springframework.security.web.access.intercept. FilterSecurityInterceptor.doFilter(FilterSecurityI nterceptor.java:83)
    at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    at org.springframework.security.oauth.provider.filter .OAuthProviderProcessingFilter.doFilter(OAuthProvi derProcessingFilter.java:182)
    at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    at org.springframework.security.oauth.provider.filter .OAuthProviderProcessingFilter.doFilter(OAuthProvi derProcessingFilter.java:202)
    at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    at org.springframework.security.web.authentication.Ab stractAuthenticationProcessingFilter.doFilter(Abst ractAuthenticationProcessingFilter.java:182)
    at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    at org.springframework.security.oauth.provider.filter .OAuthProviderProcessingFilter.doFilter(OAuthProvi derProcessingFilter.java:202)
    at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    at org.springframework.security.web.access.ExceptionT ranslationFilter.doFilter(ExceptionTranslationFilt er.java:113)
    at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    at org.springframework.security.web.session.SessionMa nagementFilter.doFilter(SessionManagementFilter.ja va:101)
    at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    at org.springframework.security.web.authentication.An onymousAuthenticationFilter.doFilter(AnonymousAuth enticationFilter.java:113)
    at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    at org.springframework.security.web.servletapi.Securi tyContextHolderAwareRequestFilter.doFilter(Securit yContextHolderAwareRequestFilter.java:54)
    at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    at org.springframework.security.web.savedrequest.Requ estCacheAwareFilter.doFilter(RequestCacheAwareFilt er.java:45)
    at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    at org.springframework.security.web.authentication.Ab stractAuthenticationProcessingFilter.doFilter(Abst ractAuthenticationProcessingFilter.java:182)
    at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    at org.springframework.security.web.authentication.lo gout.LogoutFilter.doFilter(LogoutFilter.java:105)
    at org.springframework.security.web.FilterChainProxy$ VirtualFilterChain.doFilter(FilterChainProxy.java: 323)
    at org.springframework.security.web.context.SecurityC ontextPersistenceFilter.doFilter(SecurityContextPe rsistenceFilter.java:87)

    and when I submit my form am not able to get the birthYear property value in the User object. how can it be missing while all other fields are able to get.
    Please help me with this am not familiar with this type.

    Thanks

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Please use [ code][/code ] tasg when posting code/stacktraces that way it remains eradable...

    How would you convert a String 'dsfs' into a number... That isn't possible and that is also what the stacktrace is telling you...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Yes i agree with you but over here I need to show some validation if the user enters a text in this way.. so how can I approach for this please lemme know so that I can !!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •