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 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.
posted 9 years ago
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: