You will need to set the "selectedCompanies" in the ActionForm so that the <html:multibox .../> can determine which companies have been selected by comparing the company id against the selected company id.
If "allCompanies" does not change per user, you may want to place that in the ServletContext on application startup to avoid the database hit everytime that action is executed. robert > -----Original Message----- > From: Jaakko Rytinki [mailto:[EMAIL PROTECTED] > Sent: Thursday, December 09, 2004 9:14 AM > To: Struts Users Mailing List > Subject: Multibox & DynaActionForm > > > How I can prepopulate a form containing a multibox when using > DynaActionForms? The following code doesn't seem to work - it wont check > any checkboxes (why?) > > --- > Action which prepopulates the form: > --- > > String[] companies = MyDBTools.getUser(userId).getCompanies(); > ArrayList allCompanies = MyDBTools.getAllCompanies(); > > _request.setAttribute("selectedCompanies", companies); > _request.setAttribute("allCompanies", allCompanies ); > > --- > Form > --- > > <logic:iterate id="company" name="allCompanies"> > <html:multibox property="selectedCompanies"> > <bean:write name="company" property="id"/> > </html:multibox> > <bean:write name="company" property="name"/> > <br> > </logic:iterate> > > --- > Form-bean > --- > > <form-bean > name="forms.myForm" > type="org.apache.struts.validator.DynaValidatorForm"> > > <form-property name="selectedCompanies" > type="java.lang.String[]" /> > </form-bean> > > > > --------------------------------------------------------------------- > 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]