• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to validate this scenario using validation.xml

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please help me out in doing validation for the following scenario using Validation.xml

I have a drop down With 3 state values(ex: Kentucky,Michigan) and
a textbox which will accept the claim# for the state selected.

conditions.
1. Both state dropdown and claim# can be null.
2. A value is selected from State dropdown but no values can be entered for claim#.
3. Claim# format for each of the state selected are different(for ex Kentucky takes a String of length 8 or 9, MI takes a String of length 5).

I tried both requiredif and validWhen constructs in validation.xml but its not satisfying all sceanrios.


Please help me out with the validation.

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd do it in Java: anything more complex than a single condition or a very simple two-state condition isn't worth trying to write in XML.
 
Prabu JayaPandian
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah.. Even i would like to do it that way..

But you got some crazy Team Leads and PMs out there..

SO please help me out if you have a solution
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, seriously: the limitations of validWhen makes this difficult and/or impossible. Combine the two forms of validation.

The other best option is to write and register a custom validator: this keeps the logic in Java code, where it belongs, and it more easily testable, but allows the configuration to still be entire in XML.

I won't help you with the validWhen expression--it would be too difficult to set up a way to test it, it's too finicky because of the way it was built, and substantially better options exist. Consider going the custom validator route--it's easy, and makes it look like the validation is entirely in XML, even though the tricky bits are somewhere else (where they're manageable).
reply
    Bookmark Topic Watch Topic
  • New Topic