Results 1 to 3 of 3

Thread: Commons Validator Serverside Validation

  1. #1
    Join Date
    Oct 2005
    Location
    Mobile, AL
    Posts
    345

    Default 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. #2
    Join Date
    Oct 2005
    Location
    Mobile, AL
    Posts
    345

    Default

    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.

  3. #3
    Join Date
    Dec 2005
    Location
    Canberra, Australia
    Posts
    11

    Default

    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.

Similar Threads

  1. Replies: 4
    Last Post: Mar 12th, 2010, 12:28 PM
  2. Replies: 1
    Last Post: Apr 29th, 2009, 12:36 PM
  3. Spring and commons validation
    By jkookie in forum Web
    Replies: 6
    Last Post: Sep 23rd, 2005, 12:41 PM
  4. Commons validation with wizard form controller
    By brianstclair in forum Web
    Replies: 0
    Last Post: Jan 14th, 2005, 02:14 PM
  5. Domain Object Validation
    By lhilden in forum Architecture
    Replies: 4
    Last Post: Dec 14th, 2004, 07:00 AM

Posting Permissions

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