This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Struts and the fly likes Validator range and duplicate fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validator range and duplicate fields" Watch "Validator range and duplicate fields" New topic
Author

Validator range and duplicate fields

majid nakit
Ranch Hand

Joined: Jun 26, 2001
Posts: 167
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.
roseline ruba
Greenhorn

Joined: Mar 21, 2007
Posts: 20
1. i didnot understand
2. You can try 'intRange' in struts validator.


Roseline
majid nakit
Ranch Hand

Joined: Jun 26, 2001
Posts: 167
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.
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
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
 
I agree. Here's the link: http://kickstarter.com/rocket-mass-heater
 
subject: Validator range and duplicate fields