I don't use any component and yes I am trying to bind directly to a Hibernate entity.
I think the problem in line 1004 in org.apache.commons.beanutils.BeanUtilsBean.java else if (value instanceof String[]) { newValue = getConvertUtils().convert(((String[]) value)[0], type.getComponentType()); The bind actually happens but the set is populated only with 1 value. I think that is because of ((String[]) value)[0] What do you think? BISO org.apache.commons.beanutils.BeanUtilsBean.java ------------------------------ 976 if (type.isArray() && (index < 0)) { // Scalar value into array if (value == null) { String values[] = new String[1]; values[0] = (String) value; newValue = getConvertUtils().convert((String[]) values, type); } else if (value instanceof String) { String values[] = new String[1]; values[0] = (String) value; newValue = getConvertUtils().convert((String[]) values, type); } else if (value instanceof String[]) { newValue = getConvertUtils().convert((String[]) value, type); } else { newValue = value; } } else if (type.isArray()) { // Indexed value into array if (value instanceof String) { newValue = getConvertUtils().convert((String) value, type.getComponentType()); } else if (value instanceof String[]) { 1004 newValue = getConvertUtils().convert(((String[]) value)[0], type.getComponentType()); } else { newValue = value; } } else { // Value into scalar if ((value instanceof String) || (value == null)) { newValue = getConvertUtils().convert((String) value, type); } else if (value instanceof String[]) { newValue = getConvertUtils().convert(((String[]) value)[0], type); } else if (getConvertUtils().lookup(value.getClass()) != null) { newValue = getConvertUtils().convert(value.toString(), type); } else { newValue = value; } } -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of James Carman Sent: Thursday, February 01, 2007 10:15 PM To: Jakarta Commons Users List Subject: Re: String[] to Set Converter What type of component are you using to "edit" your set? Are you trying to bind directly to a Hibernate entity with a Set property? On 2/1/07, Abbas Adel <[EMAIL PROTECTED]> wrote: > Dear Mr. James Carman > > Thanks a lot for your respond. > I think I wasn't clear enough in my email. > > I am using Struts framework with Hibernate, and I am trying to build a > BeanUtils converter to convert String[] array into a Set > > I registered my converter but unfortunately it only works with single > objects. > > ConvertUtils.register(new SetConverter(),Set.class) > > So, how could convert String[] to a Set > > Thanks for your help > BISO > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of James > Carman > Sent: Thursday, February 01, 2007 8:30 PM > To: Jakarta Commons Users List > Subject: Re: String[] to Set Converter > > Try this: > > java.util.Set s = new > java.util.HashSet(java.util.Arrays.asList(stringArray)); > > On 2/1/07, Abbas Adel <[EMAIL PROTECTED]> wrote: > > > > > > I want to Convert String[] to a java.util.Set > > > > > > > > This is my User bean > > > > > > > > public class User extends org.apache.struts.action.ActionForm { > > > > > > > > private String name; > > > > private Set values; > > > > > > > > public String getName() { > > > > return name; > > > > } > > > > > > > > public void setName( String name) { > > > > this.name = name; > > > > } > > > > > > > > public Set getValues() { > > > > return values; > > > > } > > > > > > > > public void setValues(Set values) { > > > > this.values = values; > > > > } > > > > } > > > > > > > > My struts form > > > > > > > > <html:form action="/post"> > > > > <html:text property="name"/> > > > > > > > > <html:select property="values" multiple="true"> > > > > <html:option value="1"/> > > > > <html:option value="2"/> > > > > <html:option value="3"/> > > > > <html:option value="4"/> > > > > <html:option value="5"/> > > > > > > > > <html:submit /> > > > > </html:select> > > > > </html:form> > > > > > > > > > > > > Thanks in advance > > > > > > > > BISO > > > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > __________ NOD32 2026 (20070201) Information __________ > > This message was checked by NOD32 antivirus system. > http://www.eset.com > > > > --------------------------------------------------------------------- > 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] __________ NOD32 2028 (20070201) Information __________ This message was checked by NOD32 antivirus system. http://www.eset.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]