Announcement Announcement Module
Collapse
No announcement yet.
Commons Validator Serverside Validation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Commons Validator Serverside Validation

    I am trying to incorporate the Commons Validator logic into a sample Spring mvc web application and I have successfully gotten the client side validation to work on a sample form. My problem is that I was testing the server side validation and it doesn't seem to work. I disabled the static javascript by setting the following statement in my form.jsp

    <v:javascript dynamicJavascript="false" staticJavascript="false"/>

    When I submit my form it paints a success screen. How does the server side validation exactly work?

    Is there something I need to set in a configuration file?

    Sorry for all the questions but I am a newby.

  • #2
    I found out why server side validation was not working. The validator-rules.xml file that I downloaded was an older version that had the old package names for the FieldCheck class for example:

    org.springframework.validation.commons.FieldChecks

    should have been

    org.springmodules.commons.validator.FieldChecks

    Unfortunetely the org.springmodules.commons.validator.AbstractBeanVa lidator.validate method does not do anything if a validation exception occurs!

    Hope this helps anyone having this issue.

    Comment


    • #3
      Yes, the AbstractBeanValidator tripped me up for some time when I first downloaded the commons validator module. Of course I shouldn't have written validator code that crashed, but that's another story :-)

      There is a 'todo' in the AbstractBeanValidator code:
      Code:
      public void validate(Object obj, Errors errors) {
      	org.apache.commons.validator.Validator commonsValidator = getValidator(obj, errors);
      	try {
      		commonsValidator.validate();
      	}
      	catch (ValidatorException e) {
      		// todo: throw exception here
      	}
      }
      Revision 1.2 of the code in CVS doesn't swallow the exception, but logs it, which is a huge help in debugging. Unfortunately this hasn't yet made it into a numbered release.

      Comment

      Working...
      X