Hi all, I'm new with spring framework.
I have a bean AddExameForm with this parameters:
private
String esame;
private String descrizione;
private List<Domanda> domande;
and the costructor is:
//initilize ArrayList with objects domanda
domande = new ArrayList<Domanda>(10);
for (int i=0;i<10;i++){
domande.add(new Domanda());
}
... setter and getter methods;
and bean Domanda is a bean with:
private String domanda;
... setter and getter
Now I want to populated my bean AddExameForm (with domande) and I using a binding; in the other words I want a form with 10 input (type=text) where I want to write my 10 strings (text) and then when I push a submit button I want to initialize my bean (my List domande) with my 10 strings.
My
jsp code is:
<c:forEach varStatus="i" var="domande" items="${addExameForm.domande}">
<tr>
<td class="blank"><cut value="${i.count}" /></td>
<td class="blank">
<spring:bind path="addExameForm.domande[${i.index}].domanda">
<input type="text" name="<cut value="${status.expression}"/>" value="<cut value="${status.value}"/>">
<font color="red"><cut value="${status.errorMessage}" /></font>
</spring:bind>
</td>
</tr>
</c:forEach>
when I submit form I have this error:
javax.servlet.ServletException: org.springframework.beans.InvalidPropertyException : Invalid property 'domande[0]' of bean class [springweb.form.admin.AddExameForm]: Index of out of bounds in property path 'domande[0]'; nested exception is java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
Can you help me?
Thanks Pasquy