Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
Ranch Hand
Posts: 255
  • 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:
https://coderanch.com/how-to/java/IndexedProperties

thanks.

JCE: Please use CodeTags
 
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: 255
  • 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.
 
A timing clock, fuse wire, high explosives and a tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic