• 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

Validator range and duplicate fields

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am displaying data dynamically from a database the user has to put numbers in the textfields from 1 to N (it's like a survey or vote) :

textfield1 -- caseId --- title
textfield2 -- caseId --- title
textfield3 -- caseId --- title
......

textfieldN -- caseId --- title

I want to validate :
1)a number can not duplicated.

2)the number entred should be between 1 and N (N depend of how many rows returned).

thanks, your help is appreciated.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. i didnot understand
2. You can try 'intRange' in struts validator.
 
majid nakit
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for question #2, I know about intRange , but the max is not static, the max is the number of rows passed from database, how to pass the max returned in the action to the validator xml file.
thanks.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The validator framework and the default set of rules provide a 95% solution. This type of validation falls into the 5% that is not covered. You could either develop a custom validation rule or just implement the validation in your form's validate method.

- Brent
reply
    Bookmark Topic Watch Topic
  • New Topic