hi!

i need to allow a user to enter data into a database through a form. However i dont know beforehand what the table structure will be. Looking around, the solution seems to be to use map backed forms.

What i would like to know is how do you perform error checking, bounds checking etc in such a case.
if you are going something like,
<%
Map m = (Map)request.getAttribute("FORM_MAP");
Set s = m.keySet();
Iterator iterator = s.iterator();
%>


   <% while (iterator.hasNext()){
     String key= (String)iterator.next();
     String fieldValue="field("+key+")";
   %>
   <TR>
     <TD><%=key%></TD>
     <TD><html:text property="<%=fieldValue%>">
       </html:text></TD>

you dont know what the field is, and what are valid values for the field. if the field happens to be for a phone number, how would you test whether the field contained only numbers. Also how would you set a 'maxlength' on the <html:text> tag?
As a more general question, in an application where you dont know what the database structure will be (dynamic fields) how and where would you check and validate form submissions?


So far the only way i have come up with is, to execute a Describe table query, get the field attributes and then have a whole bunch of if statements that check if the field is of type varchar, int, float etc and once i have that, check the submitted form values and see if they have the same type. A rather clumsy way.

if someone has any clues or has solved this before, please do reply.

thanks
Ajay

_________________________________________________________________
E-mail just got a whole lot better. New ninemsn Premium. Click here http://ninemsn.com.au/premium/landing.asp



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to