commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Abbas Adel" <b...@tantawi.net>
Subject RE: String[] to Set Converter
Date Thu, 01 Feb 2007 20:05:30 GMT
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: jwcarman@gmail.com [mailto:jwcarman@gmail.com] 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 <biso@tantawi.net> 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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org



__________ NOD32 2026 (20070201) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message