• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 255
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic