I'm also having trouble concerning indexed properties with BeanUtils.  If
the type of the indexed property is String, then BeanUtils.populate throws
IllegalArgumentException.

Using your NameBean in an example:

...
        NameBean nameBean = new NameBean();
        BeanUtils.populate(nameBean,new String[] {"John", "Paul", "Jack"});

        // above throws IllegalArgumentException!
...


If I take the same indexed property and change it to an int
BeanUtils.populate works!

I've posted this problem to both the jakarta-commons-dev and struts-user
lists with no response.  So I don't know if it is supported or not.  Please,
can someone give us an answer???

-----Original Message-----
From: Filipe Mateus [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 30, 2002 1:30 PM
To: [EMAIL PROTECTED]
Subject: BeanUtils


Do BeanUtils.describe and BeanUtils.populate supposed to handle indexed
properties?

Suppose I have this JavaBean:

public class NameBean {
        private String[] name;

        public String[] getName() {
                return this.name;
        }
        public void setName(String[] name) {
                this.name = name;
        }
        public String getName(int index) {
                return this.name[index];
        }
        public void setName(int index, String name) {
                this.name[index] = name;
        }
}

I would expect the following code to return a Map containing:
name[0]="John", name[1]="Paul", name[2]="Jack"
but instead, I get name="John".
Only the first element is considered.

...
        NameBean nameBean = new NameBean();
        nameBean.setName(new String[] {"John", "Paul", "Jack"});

        Map properties = BeanUtils.describe(nameBean);
...


**********************************************************************
Financiere Banque Nationale et NBCN n'assument
aucune responsabilite quant a la confidentialite et l'integrite du
present courriel en raison des risques d'interception inherents
a l'Internet. Pour cette raison, toute opinion exprimee au terme
des presentes ne reflete pas necessairement celle de
Financiere Banque Nationale et de NBCN.
**********************************************************************
Due to the security risks involved in sending information over the
Internet, National Bank Financial  and NBCN cannot be held responsible
for ensuring the confidentiality and integrity of the present e-mail. For
this
reason, the opinions expressed herein do not necessarily reflect those of
National Bank Financial and NBCN.
**********************************************************************


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to