Announcement Announcement Module
Collapse
No announcement yet.
Spring 3.1 minor issue with converter/formatter functionality Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 3.1 minor issue with converter/formatter functionality

    I have written and registered a formatter to format 'firstname lastname' string to Name object. This works fine, however my formatter is not called when i enter a empty string in the name field. So i tried adding @NotEmpty annotation and when i try the filling the form with empty name field,i get bombed out with following stack trace
    org.springframework.web.util.NestedServletExceptio n: Request processing failed; nested exception is javax.validation.UnexpectedTypeException: No validator could be found for type: com.samridh.ebulawa.web.domain.account.Name
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:894)
    org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:789)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:637)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    org.springframework.web.filter.CharacterEncodingFi lter.doFilterInternal(CharacterEncodingFilter.java :88)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    org.springframework.web.filter.HttpPutFormContentF ilter.doFilterInternal(HttpPutFormContentFilter.ja va:88)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)

    root cause

    javax.validation.UnexpectedTypeException: No validator could be found for type: com.samridh.ebulawa.web.domain.account.Name
    org.hibernate.validator.engine.ConstraintTree.veri fyResolveWasUnique(ConstraintTree.java:244)
    org.hibernate.validator.engine.ConstraintTree.find MatchingValidatorClass(ConstraintTree.java:227)
    org.hibernate.validator.engine.ConstraintTree.getI nitializedValidator(ConstraintTree.java:179)
    org.hibernate.validator.engine.ConstraintTree.vali dateConstraints(ConstraintTree.java:135)
    org.hibernate.validator.metadata.MetaConstraint.va lidateConstraint(MetaConstraint.java:121)
    org.hibernate.validator.engine.ValidatorImpl.valid ateConstraint(ValidatorImpl.java:327)
    org.hibernate.validator.engine.ValidatorImpl.valid ateConstraintsForRedefinedDefaultGroup(ValidatorIm pl.java:273)
    org.hibernate.validator.engine.ValidatorImpl.valid ateConstraintsForCurrentGroup(ValidatorImpl.java:2 56)
    org.hibernate.validator.engine.ValidatorImpl.valid ateInContext(ValidatorImpl.java:210)
    org.hibernate.validator.engine.ValidatorImpl.valid ate(ValidatorImpl.java:119)
    org.springframework.validation.beanvalidation.Spri ngValidatorAdapter.validate(SpringValidatorAdapter .java:101)
    org.springframework.validation.DataBinder.validate (DataBinder.java:722)
    org.springframework.web.method.annotation.ModelAtt ributeMethodProcessor.validateIfApplicable(ModelAt tributeMethodProcessor.java:154)
    org.springframework.web.method.annotation.ModelAtt ributeMethodProcessor.resolveArgument(ModelAttribu teMethodProcessor.java:107)
    org.springframework.web.method.support.HandlerMeth odArgumentResolverComposite.resolveArgument(Handle rMethodArgumentResolverComposite.java:74)
    org.springframework.web.method.support.InvocableHa ndlerMethod.getMethodArgumentValues(InvocableHandl erMethod.java:155)
    org.springframework.web.method.support.InvocableHa ndlerMethod.invokeForRequest(InvocableHandlerMetho d.java:117)
    org.springframework.web.servlet.mvc.method.annotat ion.ServletInvocableHandlerMethod.invokeAndHandle( ServletInvocableHandlerMethod.java:96)
    org.springframework.web.servlet.mvc.method.annotat ion.RequestMappingHandlerAdapter.invokeHandlerMeth od(RequestMappingHandlerAdapter.java:617)
    org.springframework.web.servlet.mvc.method.annotat ion.RequestMappingHandlerAdapter.handleInternal(Re questMappingHandlerAdapter.java:578)
    org.springframework.web.servlet.mvc.method.Abstrac tHandlerMethodAdapter.handle(AbstractHandlerMethod Adapter.java:80)
    org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:900)
    org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:827)
    org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:882)
    org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:789)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:637)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    org.springframework.web.filter.CharacterEncodingFi lter.doFilterInternal(CharacterEncodingFilter.java :88)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    org.springframework.web.filter.HttpPutFormContentF ilter.doFilterInternal(HttpPutFormContentFilter.ja va:88)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    case 1): The following syntax works, but my custome @NameFormat is not trigggered for empty string in the UI
    public class SignupForm {

    @NameFormat
    private Name name;
    -----
    }
    case 2): The following syntax bombs for empty string in the front end with the above exception.
    public class SignupForm {

    @NotEmpty
    @NameFormat
    private Name name;
    -----
    }
    My Question is, how do i validate for empty string?

  • #2
    Still looking for an answer or suggestion.

    Comment


    • #3
      Same problems:
      Amazon coupon codes January 2012

      Comment

      Working...
      X