If you knew the underlying data type associated with each of the ((DynaProperty)col).getName() calls in your example then you could create the input type appropriate to that data type. So, you would also need to expose the underlying datatypes to the JSP so that it could conditionally create the appropriate input type for each column. Some issues with this:
* Should the presentation layer really *know* about the underlying datatypes, Your example passes a disconnected recordset to the presentation layer so the JSP would need to know something about how that data is stored in the underlying RDBMS. * The conditional logic in the presentation tier might get quite messy - in terms of psuedo code it might look something like this: if type is boolean then create radio buttons else if type is string then create text input else if etc etc But if this is what you _have_ to do then you could try this: * Get the metadata from the underlying resultset and make this available to your JSP alongside the "rowSet" e.g. request.setAttribute("rowSetColumns", rs.getMetaData()); Then either: * Write a custom tag which encapsulates the logic required to interrogate the metadata and creates the appropriate control type OR * Use JSTL conditional tags or Struts logic tags to apply this logic in-place within the JSP. -----Original Message----- From: Javier Santos Martin-Moreno [mailto:[EMAIL PROTECTED] Sent: 08 June 2005 14:27 To: user@struts.apache.org Subject: help needed with RowSetDynaClass Hello all, I am writing a jsp that retrieves a row of a table in my database and allows the user to modify the fields using a form. For example, if I have the following table in my database: NAME GENDER John Male Ann Female and the following code in my action class ... RowSetDynaClass rowSet = dao.getUserData("John"); request.setAttribute("rowSet", rowSet); ... I would like to display in my jsp a form with a text field containing "John" and a two radio buttons labelled "male" (selected) and "female", so that these values can be modified, and a submit button to update the database. This is the piece of code of my jsp displaying the fields of the form: <logic:iterate id="row" name="rowSet" property="rows"> <logic:iterate id="col" name="cols"> <tr> <td><bean:write name="col" property="name" /></td> <td><html:text property="<%=((DynaProperty)col).getName()%>" size="30" value="<%=((DynaBean)row).get(((DynaProperty)col).getName()).toString()% >" /></td> </tr> </logic:iterate> </logic:iterate> However, this way all the fields must be the same type (text in this case) and have the same attributes (i.e. same size). I would like to know if there is any method to be able to choose the type of input field (text, select, checkbox, radio) or the attributes (size, maxlength for text) for each field of the database. Any suggestions? Thanks in advance, Javier --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -------------------------------------------------------- If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail. http://www.ml.com/email_terms/ -------------------------------------------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]