On Fri, 21 Jan 2005 21:22:23 -0600, Dave Bender <[EMAIL PROTECTED]> wrote: > I'm having a problem passing a set of checkbox values from an ActionForm to > our database. When I transfer the values of the String[] array, such as a > String[5] array, using BeanUtils.populate in my Action, the array gets > truncated and comes out as a single String value, actually a String[1]. > > What's up with that?! > > Is BeanUtils.populate() able to work with String[] arrays? If so, is there > a known bug in my particular version? (How can I tell what version of > BeanUtils I'm working with? It's bundled with Struts 1.1 and I can't seem > to match the source code versions.) > > If BeanUtils.populate is not able to work with String[] arrays, how do folks > deal with transferring checkbox-style data from a Web page, through an > ActionForm to a database? > > To chase down this problem, I wrote a simple test case that pulls up one of > our Document objects, creates a DocumentForm (an ActionForm), populates it > from the document and sees if their "selectedUserGroups" values are > different. They are. Here's the gist of it: > > Document document = new Document(cn, 10); > SearchForm searchForm = new SearchForm(); > Map map = BeanUtils.describe(document);
Please take a look at http://jakarta.apache.org/commons/beanutils/apidocs/org/apache/commons/beanutils/BeanUtilsBean.html#describe(java.lang.Object) The "map" contains the toString converted property values. ConvertUtils.convert(String[]) is called and it returns the first value in the array. > BeanUtils.populate(searchForm, map); > > At the first line, document contains a selectedUserGroups property that is a > String[] array with five values. > At the third line, map references a HashMap that contains a key for > selectedUserGroups that contains a String[] with one value. > > How do I get all the values? Any help would be appreciated. Use BeanUtils.copyProperties(dest, orig); instead > > Dave > > --------------------------------------------------------------------- > 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]