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?
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?
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.
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
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
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:
This business object was given beanValidator in my applicationContext.xml.Code:BindException errors = new BindException(cktId, "CktId"); beanValidator.validate(cktId, errors); if(errors.hasErrors()) { throw new RuntimeException(errors); }
And my validations.xml looks like this:
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.Code:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE form-validation PUBLIC "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN" "http://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="${var:maxlength}" resource="false"/> <var><var-name>maxlength</var-name><var-value>5</var-value></var> </field> </form> </formset> </form-validation>
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?
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).
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
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
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/
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.Originally Posted by olorin
Matt