Hello,
I have a problem setting form properties that have a type of String[].
I have this defined in my struts-config.xml:
<form-bean dynamic="true" name="soortopvanglocatieForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="vorm" type="java.lang.String" />
<form-property name="voorkeurenKinderdagverblijfVoorkeur"
type="java.lang.String[]" />
<form-property
name="voorkeurenBuitenschoolseopvangVoorkeur" type="java.lang.String" />
<form-property
name="voorkeurenBuitenschoolseopvangBasisschool" type="java.lang.String" />
<form-property name="voorkeurenHalvedagopvangVoorkeur"
type="java.lang.String" />
</form-bean>
Note the array of String as the type of voorkeurenKinderdagverblijfVoorkeur.
In my .jsp I have this:
<logic:iterate id="voorkeur"
name="soortopvanglocatieForm"
property="voorkeurenKinderdagverblijfVoorkeur"
indexId="i">
<html:text name="soortopvanglocatieForm"
property='<%="voorkeurenKinderdagverblijfVoorkeur[" + i + "]"%>' size="20"/>
</logic:iterate>
What happens is that the initial display of the page looks just fine.
Things start to get messy when I essentially try to add or delete a
html:text field (by trying to change the array of
voorkeurenKinderdagverblijfVoorkeur in the background).
When I hit one of the two buttons I defined, Struts start parsing the
POST information but halts in the bean populate() section:
java.lang.ArrayIndexOutOfBoundsException
at java.lang.reflect.Array.set(Native Method)
at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:457)
at
org.apache.commons.beanutils.PropertyUtils.setIndexedProperty(PropertyUtils.java:1414)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1013)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1097)
at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:798)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:523)
I debugged this in the source and the array that is to be set by
Array.set is of type String[0].
And the particular instance that is being set is at index 1.
Anyway, it seems that the array properties in the DynaValidatorForm we
are using aren't being allocated.
Any ideas or hints?
We use Struts 1.1b3, bean-utils 1.6.1.
Regards, Richard.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]