views:

89

answers:

1

[Warning] I'm new to JSP/Struts/JSTL. This is probably a newbie question :)

I have a form that contains a collection:

public class ServiceForm extends AbstractForm
{   
    private List<SrvDO> allSrv = new ArrayList<SrvDO> ();  
}

I can see the object data correctly in my form using the JSP. The page displays 5 input box with the data from the database correctly:

<c:forEach items="${serviceForm.allSrv}" var="srv">         
    <html:text name="srv" property="nbDays"/> 
 </c:forEach>   

<html:submit/>

But when I press the submit button, the form does not contains the updated data for "nbDays". I still see the same data as it was shown before the update. What am I missing that says to struts: for each srv, update the "nbDays" data?

+1  A: 

Found the answer on the spring forum:

Your form:input tag doesn't and shouldn't know anything about the fact that it is used inside another tag. That is why you need to include the index.

So the solution is:

<html:text property="allSrv[${srvSta.index}].nbDays"/>
Thierry-Dimitri Roy