You simply need a property in your ActionForm that returns a collection of "skill" beans and used the "indexed" attribute on the <html> tags. The "isssue" that most people have problems with is when using a "Request" scope ActionForm you need to populate your collection with the right number of skill beans - the way to handle this is some kind of "lazy list" processing for that property. Search the archives on indexed properties and lazy list processing.
In your jsp... <logic:iterate name="skillsForm" property="skills" id="skills"> <html:text name="skills" property="skillid" indexed="true"/> <html:select name="skills" property="skillLevel" indexed="true"> <html:option value="1">Low</html:option> <html:option value="2">Medium</html:option> <html:option value="3">High</html:option> </html:select> </logic:iterate> The trick is to name the "id" attribute to the same as the property in the form which returns the collection, that way Struts will generate something like: <input type="text" name="skills[x].skillid value=".."/> The lazy ActionForms I wrote have the lazy list behaviour built in.... http://www.niallp.pwp.blueyonder.co.uk/#lazydynabean Niall ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, September 30, 2004 6:19 PM Subject: How to handle multiploe unknown form fields > I have an interesting situation, one that has never come up before, and I'm unsure how to deal with it... > > Imagine you have some records from a database representing various skills (i.e., HTML, Javascript, J2EE, etc.). Each has a SkillID associated with it. > > You create a JSP that lists each skill with a drop-down next to it. The drop-down allows the user to select their skill level for each skill. > > When the user hits Save, you need to update all the skills for that user. > > That's the scenario. Here's the question... Each drop-down is given the name of the SkllID. But how do you write an ActionForm for that? > > Since the database can be expanded to include new skills at any time, it's impractical to add getters and setters for each SkillID, and in fact breaks low coupling goals anyway. > > Is there a standard way of accepting what kind of amounts to an array of inputs from a form and getting it into an ActionForm in some way (maybe as an ArrayList or something?). > > TIA! --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]