RE: In regards to Struts 2 Validation.
Fair enough. But HV still doesn't have a full set of validation features in my opinion. Perhaps we should discuss what is wrong with our current validation support, and what we want to accomplish. I believe all we need are some simple changes to take us most of the way there. My personal thoughts have been captured here (just replace the word OVal with Struts2 Validation): http://sourceforge.net/forum/forum.php?thread_id=1889936forum_id=488109 Date: Tue, 11 Dec 2007 03:38:50 -0800 From: [EMAIL PROTECTED] To: dev@struts.apache.org Subject: Re: In regards to Struts 2 Validation. Hmmm, I'd say that it's still a safe bet that Hibernate Validator will have a profound effect on JSR 303, akin to JPA and Hibernate Core. I've seen posts on the Hibernate list that imply JSR 303 will be backwardly compatible with HV. -Ted. On Dec 10, 2007 4:37 PM, Bob Tiernay [EMAIL PROTECTED] wrote: I believe that OVal will soon be a referenced as existing technology for this JSR: http://sourceforge.net/forum/forum.php?thread_id=1640398forum_id=488109 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Exercise your brain! Try Flexicon! http://puzzles.sympatico.msn.ca/chicktionary/index.html?icid=htmlsig
Re: In regards to Struts 2 Validation.
A good place to start might be with a set of use cases that demonstrate various validation scenarios. We could then try to implement the use cases using the XW validation, Commons validator, and Hibernate Validator, and compare the outcome. -- HTH, Ted * http://www.StrutsMentor.com/ On Dec 12, 2007 5:18 AM, Bob Tiernay [EMAIL PROTECTED] wrote: Fair enough. But HV still doesn't have a full set of validation features in my opinion. Perhaps we should discuss what is wrong with our current validation support, and what we want to accomplish. I believe all we need are some simple changes to take us most of the way there. My personal thoughts have been captured here (just replace the word OVal with Struts2 Validation): http://sourceforge.net/forum/forum.php?thread_id=1889936forum_id=488109 Date: Tue, 11 Dec 2007 03:38:50 -0800 From: [EMAIL PROTECTED] To: dev@struts.apache.org Subject: Re: In regards to Struts 2 Validation. Hmmm, I'd say that it's still a safe bet that Hibernate Validator will have a profound effect on JSR 303, akin to JPA and Hibernate Core. I've seen posts on the Hibernate list that imply JSR 303 will be backwardly compatible with HV. -Ted. On Dec 10, 2007 4:37 PM, Bob Tiernay [EMAIL PROTECTED] wrote: I believe that OVal will soon be a referenced as existing technology for this JSR: http://sourceforge.net/forum/forum.php?thread_id=1640398forum_id=488109 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Exercise your brain! Try Flexicon! http://puzzles.sympatico.msn.ca/chicktionary/index.html?icid=htmlsig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: In regards to Struts 2 Validation.
I have plenty of examples from our application. The first is a case where the user must enter at least one phone number and if the type of phone is selected, then the user must enter a phone number. The validation code is as follows: if(!hasFieldErrors(exampleData.phoneNumber1) !hasFieldErrors(exampleData.phoneNumber2) !hasFieldErrors(exampleData.phoneNumber3) !hasFieldErrors(exampleData.phoneNumber4)) { if((!exampleData.getPhoneNumber1().equals() exampleData.getPhoneType1()== 0) || (!exampleData.getPhoneNumber2().equals() exampleData.getPhoneType2()== 0) || (!exampleData.getPhoneNumber3().equals() exampleData.getPhoneType3()== 0) || (!exampleData.getPhoneNumber4().equals() exampleData.getPhoneType4()== 0)) { addActionError(getText(phoneType.error)); } if((exampleData.getPhoneNumber1().equals() exampleData.getPhoneType1()!= 0) || (exampleData.getPhoneNumber2().equals() exampleData.getPhoneType2()!= 0) || (exampleData.getPhoneNumber3().equals() exampleData.getPhoneType3()!= 0) || (exampleData.getPhoneNumber4().equals() exampleData.getPhoneType4()!= 0)) { addActionError(getText(phoneNumber.error)); } } Note, I did not write this, this is taken straight from our source code. The second example I have is a case where we want to use some logic to validate prescription information. The validation for prescriptions is tricky because the user doesn't have to enter prescriptions, but if anything is entered for a prescription, then the prescription data is fully validated. Note that we have several places in the app where this is done so I'd prefer not to duplicate this validation logic in all the places we need it. (i.e. don't want to violate the DRY principle) I broke this out into a helper class for reusability. The isEmpty() method on PrescriptionData checks to see if there is any data populated. public void validate(String propertyPrefix, List prescriptionList, ValidationAware errors, TextProvider textProvider) { for (int i = 0; i prescriptionList.size(); i++) { PrescriptionData data = (PrescriptionData) prescriptionList.get(i); // pull out conversion errors and set original values ActionInvocation invocation = ActionContext.getContext().getActionInvocation(); Map conversionErrors = invocation.getInvocationContext().getConversionErrors(); if (!data.isEmpty()) { if (data.getApplicantId() == 0) { errors.addFieldError(medication, textProvider .getText(medicalQuestions.applicant.required)); } if (ValidationUtils.isStringEmpty(data.getMedication())) { errors.addFieldError(medication, textProvider .getText(medicalQuestions.medication.required)); } if (ValidationUtils.isStringEmpty(data.getDescription())) { errors.addFieldError(description, textProvider .getText(medicalQuestions.dosage.required)); } if (!hasConversionError(propertyPrefix + [ + i + ].startDate, conversionErrors) data.getStartDate() == null) { errors.addFieldError(startDate, textProvider .getText(medicalQuestions.startDate.required)); } if (data.getStartDate() != null data.getEndDate() != null) { Calendar startCal = Calendar.getInstance(); startCal.setTime(data.getStartDate()); Calendar endCal = Calendar.getInstance(); endCal.setTime(data.getEndDate()); if (startCal.after(endCal)) { errors.addActionError(textProvider.getText(medicalQuestions.startAfterEnd)); } } } } } The final example is a case where some might consider it a 'business rule', however, in my opinion, validation is validation regardless of whether you're implementing business rule validation or simple UI validation. My argument for this is the fact that the simple UI validation is used as part of the business rule validation. (For example, you might need to check that a string is not blank or null) In this use case, we allow the user to enter a state and a zip and we verify that the state and zip match. We do this by making sure that the combination of state and zip produce at least one valid county. if (!hasFieldErrors(siteLocationView.zip) !hasFieldErrors(siteLocationView.state)) { CountyData counties[] = siteLocationProcess.getCountiesForZipAndState(siteLocationView .getZip(), siteLocationView.getStateAbbr()); if (counties.length 1) { addActionError(getText(siteLocationView.zipcountymismatch.error)); } } This is a case where the validation is dependent on a business process object. There's plenty more where that came from, so if you need more examples, I'd be happy to provide them. These examples show how verbose the
Re: In regards to Struts 2 Validation.
Hmmm, I'd say that it's still a safe bet that Hibernate Validator will have a profound effect on JSR 303, akin to JPA and Hibernate Core. I've seen posts on the Hibernate list that imply JSR 303 will be backwardly compatible with HV. -Ted. On Dec 10, 2007 4:37 PM, Bob Tiernay [EMAIL PROTECTED] wrote: I believe that OVal will soon be a referenced as existing technology for this JSR: http://sourceforge.net/forum/forum.php?thread_id=1640398forum_id=488109 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: In regards to Struts 2 Validation.
On Dec 10, 2007 7:02 AM, Philip Luppens [EMAIL PROTECTED] wrote: On Dec 9, 2007 7:42 AM, Tom Schneider [EMAIL PROTECTED] wrote: Just wanted to chime in here. I have very specific goals that I am trying to achieve, so I thought I would explain them in detail. (this is something I've been tasked with at work) [snip] So that's where I'm currently at. I haven't had much time yet to really dig into this yet. Any additional ideas/suggestions would be greatly appreciated. Tom Are there any known implementations of JSR 303 (Bean Validation) [1] yet ? Jason Carreira started that one some time ago, (based on XWork's validation, I assume). I thought the spec was pretty dead until I saw they're actually giving a session at JavaPolis this week. The spec lead has recently been changed from Jason to Emmanuel Bernard (Red Hat) so there should be progress on this JSR now. Niall [1] http://jcp.org/en/jsr/detail?id=303 - Phil rburton wrote: Tom Schneider and a few other folks have been talking about validation in Struts 2 and how it can be improved. I figured it would be useful to spawn a thread in order to stir up some idea's that may help inspire us. I know validation isn't an easy task, and some would argue it's a cross cutting concern; so does anyone have any idea's on what they would like to see done? How can the existing validation framework be improved? My only issue with the existing validation framework is I can't define validation rules which can be referenced in my validation.xml file. Any ideas would be greatly appreciated! Struts 2 = :rules: Best Regards, Richard L. Burton III P.S. I hate being at work on Sunday morning at 1 AM EST time to do a migration. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: In regards to Struts 2 Validation.
I believe that OVal will soon be a referenced as existing technology for this JSR: http://sourceforge.net/forum/forum.php?thread_id=1640398forum_id=488109 As far as I can tell, they have the most powerful set of features including support for: - AOP (AspectJ) - Spring integration (Validation interface) - BeanShell / ruby / ognl / js / mvel / groovy constraint expressions - JPA annotation validation hooks (ex @javax.persistence.OneToOne = @net.sf.oval.constraints.AssertValid) - Profiles (Multiple configurations per class that allow for runtime switching) - Object invariants / preconditions / postconditions - XML annotation overriding It's worth considering some of there approaches for s2 validation, if not leveraging OVal as a s2 plugin. On Dec 10, 2007 7:02 AM, Philip Luppens wrote: On Dec 9, 2007 7:42 AM, Tom Schneider wrote: Just wanted to chime in here. I have very specific goals that I am trying to achieve, so I thought I would explain them in detail. (this is something I've been tasked with at work) [snip] So that's where I'm currently at. I haven't had much time yet to really dig into this yet. Any additional ideas/suggestions would be greatly appreciated. Tom Are there any known implementations of JSR 303 (Bean Validation) [1] yet ? Jason Carreira started that one some time ago, (based on XWork's validation, I assume). I thought the spec was pretty dead until I saw they're actually giving a session at JavaPolis this week. The spec lead has recently been changed from Jason to Emmanuel Bernard (Red Hat) so there should be progress on this JSR now. Niall _ Discover new ways to stay in touch with Windows Live! Visit the City @ Live today! http://getyourliveid.ca/?icid=LIVEIDENCA006 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: In regards to Struts 2 Validation.
On Dec 9, 2007 7:42 AM, Tom Schneider [EMAIL PROTECTED] wrote: Just wanted to chime in here. I have very specific goals that I am trying to achieve, so I thought I would explain them in detail. (this is something I've been tasked with at work) [snip] So that's where I'm currently at. I haven't had much time yet to really dig into this yet. Any additional ideas/suggestions would be greatly appreciated. Tom Are there any known implementations of JSR 303 (Bean Validation) [1] yet ? Jason Carreira started that one some time ago, (based on XWork's validation, I assume). I thought the spec was pretty dead until I saw they're actually giving a session at JavaPolis this week. [1] http://jcp.org/en/jsr/detail?id=303 - Phil rburton wrote: Tom Schneider and a few other folks have been talking about validation in Struts 2 and how it can be improved. I figured it would be useful to spawn a thread in order to stir up some idea's that may help inspire us. I know validation isn't an easy task, and some would argue it's a cross cutting concern; so does anyone have any idea's on what they would like to see done? How can the existing validation framework be improved? My only issue with the existing validation framework is I can't define validation rules which can be referenced in my validation.xml file. Any ideas would be greatly appreciated! Struts 2 = :rules: Best Regards, Richard L. Burton III P.S. I hate being at work on Sunday morning at 1 AM EST time to do a migration. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Software Architect - Hydrodesk Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - John F. Woods - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: In regards to Struts 2 Validation.
Just wanted to chime in here. I have very specific goals that I am trying to achieve, so I thought I would explain them in detail. (this is something I've been tasked with at work) 1. We have a core product that is 'customized' for several client implementations. Validation is an area where we have a need to 'customize' certain validation rules. I think a way to separate out 'rules' that can be referenced via a key and replaced via configuration would work well here. Sort of a 'lite' rules engine targeted specifically to validation. 2. Ideally I would want to combine our current XML and action.validate validation. Right now we do the simple validation in XML and the rest of the validation in action.validate. I would prefer to have all validation in one place. 3. I want to be able to share validation between batch processes and the UI. Right now it's somewhat challenging to reuse validation between UI and batch processes. I would like one validation framework for both UI validation and validation in batch processes--at least for writing of the rules is concerned. Obviously there would need to be different adapters to invoke the validation in different contexts. 4. Validation should be easy to write and easy to use. I don't want a framework that is overly complex and hard to figure out. This is to satisfy the KISS principle. (Keep it simple stupid) So far, I like the grails validation the best. They have the concept of a 'constraint', which is like a rule but can be referenced directly in the groovy closure that defines the validation constraints. It should be easy enough to create new closures that define more complex validation directly in the closure. The other 2 projects I've looked at are: http://oval.sourceforge.net/ and https://springmodules.dev.java.net/docs/reference/0.8/html/validation.html#beanValidator. Both have some interesting concepts, but neither of them satisfy all of my needs out of the box. So that's where I'm currently at. I haven't had much time yet to really dig into this yet. Any additional ideas/suggestions would be greatly appreciated. Tom rburton wrote: Tom Schneider and a few other folks have been talking about validation in Struts 2 and how it can be improved. I figured it would be useful to spawn a thread in order to stir up some idea’s that may help inspire us. I know validation isn’t an easy task, and some would argue it’s a cross cutting concern; so does anyone have any idea’s on what they would like to see done? How can the existing validation framework be improved? My only issue with the existing validation framework is I can’t define validation rules which can be referenced in my validation.xml file. Any ideas would be greatly appreciated! Struts 2 = :rules: Best Regards, Richard L. Burton III P.S. I hate being at work on Sunday morning at 1 AM EST time to do a migration. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]