This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Struts and the fly likes How to Validate this? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to Validate this?" Watch "How to Validate this?" New topic

How to Validate this?

Dev Brazil

Joined: Jan 06, 2005
Posts: 1

I have one form that it repeats some times some fields. However the same ones have the same property, as make for validate them?

See the example:

[ January 06, 2005: Message edited by: Dev Brazil ]
Jason Menard

Joined: Nov 09, 2000
Posts: 6450
"Dev Brazil",

Welcome to JavaRanch! We don't have many rules here, but we do have a naming policy which we strictly enforce. Please re-read this policy and edit your display name in order to comply. Thanks in advance, and we look forward to seeing you around the Ranch.
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
Struts does allow for indexed properties. So, you could do something like:

Or something very close to ... I'd check out the Struts documentation pages on indexed, mapped, and nested properties.

s penumudi
Ranch Hand

Joined: Nov 17, 2004
Posts: 113
I guess you wanted to know how to validation a form field if there is more than one form field with same name.

Solition would to define a array of the form field in your Action form, get each value and validate.

For example,

If there is a form field with name "f1" repeating in your form, then in the ActionForm have a getter and setter methods for f1[]. When your form is submitted, the values will be set to this array.

from your validate method, validate the values of form field by looping through the array f1[].

Hope this helps
I agree. Here's the link:
subject: How to Validate this?
It's not a secret anymore!