The problem you're running into is that your form bean doesn't match the
Bean pattern for indexed properties.  In the populate method of the
BeanUtil class a check for IndexedPropertyDescriptor is done on the form
bean.  The javadocs for IndexedPropertyDescriptor state:

... if the argument name is "fred", it will assume that there is an
indexed reader method "getFred", a non-indexed (array) reader method
also called "getFred", an indexed writer method "setFred", and finally a
non-indexed writer method "setFred". 

So to have a "correct" Bean, you need two getters and two setters for an
indexed property.  One for the entire array and one for an individual
element of the array.  

I've always though it is a bit confusing that the tags use the
non-indexed reader while the BeanUtils use the index writer.  That's how
it will populate the page initially but not populate the bean on the
post.  

Hope this helps

bsr


-----Original Message-----
From: Alex Colic [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, March 05, 2002 3:20 PM
To: Struts
Subject: How to fill a String[] property-updated question.?


Hi,

just an update. Before I access the page I initialized the String[]
array elements to 1...6. When I get to the page the values in the
String[] array are properly displayed in the corresponding text boxes
but when I submit the page I get the following error:

java.lang.IllegalArgumentException: array element type mismatch
        at
org.apache.struts.util.PropertyUtils.setIndexedProperty(PropertyUtils.ja
va:8
51)
        at
org.apache.struts.util.PropertyUtils.setIndexedProperty(PropertyUtils.ja
va:7
85)

I don't understand why I can view the elements but not save the
elements.

Thanks for any info.

Alex


--
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