Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Jakarta Commons Validator integration?

  1. #1
    Join Date
    Aug 2004
    Posts
    9

    Default Jakarta Commons Validator integration?

    Has anyone worked on integrating Jakarta Commons Validator with Spring? It's the Validator framework used by Struts. If you have can you share your code?

  2. #2
    Join Date
    Aug 2004
    Location
    Hawaii, US
    Posts
    225

    Default

    It's actually already integrated. In fact, there is even an xdoclet module to generate the XML. It's in the sandbox currently. There are some issues waiting to be resolved before it will get integrated into project. Some issues may never be resolved, though.

    Good news is that it works fine.

  3. #3
    Join Date
    Aug 2004
    Location
    Germany
    Posts
    24

    Default

    Daniel Miller added Support, see:
    http://sourceforge.net/mailarchive/f...forum_id=28401
    and Matt Raible got a some further explanations in his Spring live book see:
    http://www.jroller.com/page/raible
    or
    http://www.sourcebeat.com/TitleAction.do?id=7
    HtH

  4. #4
    Join Date
    Aug 2004
    Location
    Denver
    Posts
    249

    Default

    Here's an updated how to:

    http://www.jroller.com/page/raible/2...or_with_spring

    If you're going to use this, you might want to be aware of this issue:

    http://opensource.atlassian.com/proj...browse/SPR-238

    Matt

  5. #5
    Join Date
    Aug 2004
    Location
    Tampa, FL
    Posts
    39

    Default Commons Validator for business tier?

    I am trying to use the Commons Validator support, except I am trying to use it for business tier validations. I followed the directions from Matt Raible's blog (except for step 4 since that didn't apply). I have code in a business object to invoke validation on an object:

    Code:
            BindException errors = new BindException(cktId, "CktId"); 
            beanValidator.validate(cktId, errors);
            if(errors.hasErrors())
            {
                throw new RuntimeException(errors);
            }
    This business object was given beanValidator in my applicationContext.xml.

    And my validations.xml looks like this:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN" "http&#58;//jakarta.apache.org/commons/dtds/validator_1_0.dtd">
    <form-validation>
     <formset>
      <form name="CktId">
        <field
          property="issue"
          depends="required,maxlength">
          <arg0 key="issue.label"/>
          <arg1 name="maxlength" key="$&#123;var&#58;maxlength&#125;" resource="false"/>
          <var><var-name>maxlength</var-name><var-value>5</var-value></var>
        </field>
      </form>
     </formset>
    </form-validation>
    I've tried violating both required and maxlength validations, but I get back no errors in both cases. The RuntimeException never gets thrown. It appears to be at least recognizing the validation.xml file, because if I mislabel the form name tag, I get an error in my logs.

    Note that I don't have any message resources configured (not sure how to do that yet), so the message keys ("issue.label") will not resolve to anything, but could that cause the problem?

  6. #6
    Join Date
    Aug 2004
    Location
    Tampa, FL
    Posts
    39

    Default

    Found my problem... I changed "CktId" to "cktId" in both parts of the code I posted. I had tried that before, but the problem then was that I was not using validation-rules.xml that is specific for Spring (I was using the original Commons version of it).

  7. #7
    Join Date
    Aug 2004
    Location
    Germany
    Posts
    24

    Default

    are there any news about moving this out of the sandbox into regular release?
    it is also mentioned in the confluence, see http://opensource.atlassian.com/conf...omments=tr ue

  8. #8
    Join Date
    Sep 2004
    Location
    St Stevens Woluwe, Belgium
    Posts
    8

    Default

    Anyone knows if Daniel's integration supports showing all form errors in one javascript popup?

    tnx,

    jan
    I've got plenty of java and Chesterfield Kings
    Donald Fagan - The nightfly

  9. #9
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    In terms of alternative validation approaches, we're using Spring's standard Validator interface along with fValidate, which is very feature-rich. Take a look at the demo if you're after a quality JavaScript-based solution: http://www.peterbailey.net/fValidate/demo/

  10. #10
    Join Date
    Aug 2004
    Location
    Denver
    Posts
    249

    Default

    Quote Originally Posted by olorin
    Anyone knows if Daniel's integration supports showing all form errors in one javascript popup?
    Yes, it does. You can see a demo at http://demo.raibledesigns.com/appfus...ng/signup.html. Just hit the signup button w/o entering in any of the required fields.

    Matt

Similar Threads

  1. Commons FileUpload with Spring
    By spring04 in forum Architecture
    Replies: 1
    Last Post: Sep 10th, 2009, 02:24 AM
  2. Replies: 3
    Last Post: Apr 5th, 2005, 09:20 PM
  3. Replies: 2
    Last Post: Nov 25th, 2004, 03:41 PM
  4. Replies: 1
    Last Post: Nov 25th, 2004, 11:08 AM
  5. Commons Validator integration
    By sjivan in forum Web
    Replies: 3
    Last Post: Oct 14th, 2004, 04:22 PM

Posting Permissions

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