0

I have an arraylist containing some fields values of which i need to display in text fields. I am using spring form for this purpose. My area of concern i am not being able to display the field values because there is a parent bean in place. I know we can do something like this form:input path="xxx" value="${arraylist.get(0).element}" , however i am not being able to understand how to access the elements when they are wrapped in a parent bean. Please help!

1
  • Not sure whether it is possible to bind directly to generic collections with Spring. It would be better to use wrapper bean as suggested by Debojit Saikia. Commented Oct 4, 2013 at 7:50

1 Answer 1

1

Assuming you have a wrapper parent bean, which contains Child instances in it:

class Parent{

Child child;
...
}

and assuming you have a list containing instances of this Parent; you can display the properties of child as below:

<c:forEach var="parent" items="${parents}" varStatus="status">
<form:input path="parents[${status.index}].child.childProperty" />
</c:forEach>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.