This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes Validation for the Indexed properties dynamic fields in struts (JSP)  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validation for the Indexed properties dynamic fields in struts (JSP)  " Watch "Validation for the Indexed properties dynamic fields in struts (JSP)  " New topic
Author

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

Rithanya Laxmi
Ranch Hand

Joined: Jan 24, 2011
Posts: 135
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

Joined: Aug 02, 2006
Posts: 66
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

Joined: Jan 24, 2011
Posts: 135
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Validation for the Indexed properties dynamic fields in struts (JSP)
 
Similar Threads
problem with html:optionsCollection
Form Params not passed properly
doubt regarding <html:select>
JSTL conversion for struts 1.1 code
Retrieving radio selection & checkbox selection from a DynaForm