1

I have a form in spring mvc 2 having command class "Class1"

I want to bind Class3 elements with an input field in this form. Below are my classes.

I am iterating/binding over Class2 elements in JSP other than map like this

<c:forEach var="item" items="${class1.class2List}" varStatus="itemsRow">  
    <form:input path="class2List[${itemsRow.index}].anyElement2" />
    ..........
</c:forEach>

My Classes looks like

Class1
List<Class2> class2List;
String anyElement1;

Class2
Map<String, Class3> class2Map;
String anyElement2;

Class3
Map<String, Class3> class3Map;
String nameToGet;
String anyElement3;

How can I bind anyElement3 inside class3Map. Is it possible?

Edited for first Answer

Caused by: org.springframework.beans.NullValueInNestedPathException: Invalid property 'class2List[0].class2Map[0]' of bean class [com.Class1]: Could not instantiate property type [com.Class3] to auto-grow nested property path: java.lang.InstantiationException: com.Class3
    at org.springframework.beans.BeanWrapperImpl.newValue(BeanWrapperImpl.java:641)
Muhammad Imran Tariq
  • 22,654
  • 47
  • 125
  • 190
  • How do you set the class2List in your DAO and map it back to the object? Asking because i am having some problems – devdar Mar 21 '13 at 22:03
  • 1
    My DAO and class2List are different classes. I fill class2List object from JSP and then set the values of DAO object using these values. – Muhammad Imran Tariq Mar 22 '13 at 05:07
  • You may have used ResultSetExtractor in your DAO can you look at this question for me and post an e.g. of how you used ResultSetExtractor http://stackoverflow.com/questions/15555163/parameterizedrowmapper-that-maps-object-list-to-object – devdar Mar 22 '13 at 10:52
  • Sorry I did not use ResultSetExtractor – Muhammad Imran Tariq Mar 22 '13 at 11:14
  • Can you show me how you did row mapping to your list items in your class in the DAO? – devdar Mar 22 '13 at 15:12
  • You class 3 for e.g you have two string attributes and one Map so if you have to set class 3 you have to set a list of items for class3Map and two Strings. I am interested in how you may have used rowmapper to achieve this for class3Map. – devdar Mar 22 '13 at 15:16

2 Answers2

5

Assuming your class2Map has an entry with key, say, mapkey, try this:

<form:input path="class2List[${itemsRow.index}].class2Map['mapkey'].anyElement3" />
adarshr
  • 61,315
  • 23
  • 138
  • 167
0

org.springframework.beans.NullValueInNestedPathException: Invalid property 'prsCDData[Forced][0]'

As in above exception how would you have property 'prsCDData[Forced][0]' in any object? . I think your path value is wrong.

smile
  • 498
  • 7
  • 18