I found the answer to my question. But this is not a solution for my requirement, since I need to implement a dynamic list. but I found a solution for this question.
As I understand it, the first time we have to send data from the back to bind input elements. I have not found a way to bind form elements that accept input without sending list data from the end. But when we send data and bind elements, we can enter data from these elements. Therefore, I think, in order to bind an element in such a situation, we must first send the data. Correct me if this statement is incorrect. Because it would be a more suitable solution for me.
We need to use a lazy list, and the jsp code will be changed.
Your command class object must be created as follows.
import org.apache.commons.collections.list.LazyList; import org.apache.commons.collections.FactoryUtils; public class SubDevisonDto { private String devId; private List subDevisions = LazyList.decorate( new ArrayList(), FactoryUtils.instantiateFactory(SubDivison.class));
The JSP code should look like this.
<c:forEach items="${subs.subDevisions}" var="obj" varStatus="gridRow">
Linking an input item text field
<spring:bind path="subdivisondto.subDevisions[${gridRow.index}].subDivisonName"> <span class="formw"><input name="<c:out value="${status.expression}"/>" type="text" style="width:350px;" />
binding an input element. This input element contains a list.
<spring:bind path="subs.subDevisions[${gridRow.index}].users"> <c:forEach items="${obj.users}" var="dependenttwo" varStatus="dependentRowtwo"> <li> <input name="<c:out value="${status.expression}"/>" type="checkbox" class="users" value="<c:out value="${dependenttwo}"/>"/> <c:out value="${dependenttwo}"/> </li> </c:forEach> </spring:bind> `subs` is a map key name. the value for this key `subs` is a list of my DTO objects which named as `SubDevisonDto `
This code works great for me.
Thanks for the support provided.