Here is the Data structure: I have two tables (Services, Documents) I hit the database and pull two separate Collections. I need to iterate over both collections... here is the relationship:
ServiceID ServiceName Documents DocumentID DocumentName So a service object contains a collection of documents.... I need to be able to output something like: <input type="checkbox" name="ServiceID[0].id" value="DocumentID">DocumentName --- <input type="checkbox" name="Catering[0].id" value="001">Contract <input type="checkbox" name="Catering[1].id" value="002">Deposit <input type="checkbox" name="Party[0].id" value="001">Contract <input type="checkbox" name="Party[1].id" value="002">Deposit In my action, I created a DynaActionForm. I set a java.util.ArrayList property called requiredDocuments in struts-config.xml In my action I make the database calls, then I iterate the services collection creating a RequiredDocumentsBean (contains serviceID, serviceName, and documents Collection) I populate the first two properties (serviceID, and serviceName) and then iterate the documents collection setting a LabelValueBean Here is the code: <-- snip --> while(sIterator.hasNext()){ // for each service... RequiredDocumentsBean rd = new RequiredDocumentsBean(); ServiceBeanLocal service = (ServiceBeanLocal)sIterator.next(); rd.setServiceId(service.getId()); rd.setServiceName(service.getServiceName()); Iterator dIterator = documents.iterator(); while(dIterator.hasNext()){ // for each available document DocumentBeanValue document = DocumentBeanValue)dIterator.next(); rd.getRequiredDocuments().add(new LabelValueBean(document.getDocumentName(),document.getId())); } requiredDocuments.add(rd); } myForm.set("allRequiredDocuments",requiredDocuments); request.setAttribute("allRequiredDocuments",requiredDocuments); <-- snip --> Thanks -----Original Message----- From: Ray Madigan [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 07, 2004 3:09 PM To: Struts Users Mailing List Subject: RE: DynaAction or Map Backed Form? It isn't clear what you have to work with. Is services a map of some sort, or is it a collection. Either way you should use the iterate tag in the logic tag set. If you could explain the data structure better, it would be easier to help. -----Original Message----- From: Amin Lalji [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 07, 2004 12:39 PM To: 'Struts Users Mailing List' Subject: RE: DynaAction or Map Backed Form? Sorry... to add... Each Service may have a unknown set of documents... E.g. Services: 001 Catering 002 Party Documents: 001 Contract 002 Deposit Should yield: <input type="checkbox" name="Catering[0].id" value="001">Contract <input type="checkbox" name="Catering[1].id" value="002">Deposit <input type="checkbox" name="Party[0].id" value="001">Contract <input type="checkbox" name="Party[1].id" value="002">Deposit Thanks, /A -----Original Message----- From: Amin Lalji [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 07, 2004 2:28 PM To: 'Struts Users Mailing List' Subject: DynaAction or Map Backed Form? Hello All, I have the following scenario: I need to populate a form using a runtime generated set of form properties... Essentially I have two collections I pull from a database Services (serviceID,serviceName) Documents (documentID,documentName) I want to populate a set of checkboxes for each service such that I achieve: <input type="checkbox" name="serviceName[0].id" value="documentID">documentName Any ideas? Thanks, Amin --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]