Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation for the Indexed properties dynamic fields in struts (JSP)

 
Rithanya Laxmi
Ranch Hand
Posts: 185
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a JSP which will display the fields dynamically based on the Id which is passed to the DB , I am using indexed properties to fetch the data when you click the submit , how to do a validation for these dynamic fields.

Here is the snippet


particularly here the "fieldType" in the form may be a text, textarea or a dropdown all these will use the same name="fieldtype". eventhough it is indexed how to do validate the "fieldtype" for a particular "fieldName" ?

I tried with validate() in the ActionForm, but without any luck as it will validate for all the 3 here which is text, textarea or a dropdown as well if they are displayed.
Please shed some light into this.

I was going through this link:
http://www.coderanch.com/how-to/java/IndexedProperties

thanks.

JCE: Please use CodeTags
 
srikanth arroju
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Laxmi,

I have used Indexed form in one of my Application. i have written a validation method in my action class .that method has a list as a parameter.
that list contains all the indexed propeties. and this method will return a hash map. which contains all the error messages of indexed properties.
and i will show the hash map values to the user.

 
Rithanya Laxmi
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Srikanth, but my problem here is :-

Since the fieldType is dynamic as it can be a textfield , dropdown or a textarea with the same name="fieldType", how i can figure out this fieldType belongs to a particular fieldName. Like "Name" fieldName with a "Textfield" will have a mandatory validation check, "Age" fieldName with a "Dropdown" will not have a mandatory validation check?

Please shed some light into this and thanks for the response.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic