Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Validate this?

 
Dev Brazil
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

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:



Thanks.
[ January 06, 2005: Message edited by: Dev Brazil ]
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic