0

I'm having trouble getting this to work. I'll keep my code and idea generic since I've seen a few examples of people with similar problems:

The basic idea is that the view has a list of order items with properties that the user can modify inside a form. When the user submits the form, I want the order items populated with the data that the user submitted.

How do I create the HTML form that populates this @ModelAttribute("orderItems") which is an ArrayList of OrderItemBeans

Controller Code:

@RequestMapping("/order/{orderId}/save")
public String saveOrder(Map<String, Object> map, @ModelAttribute("orderItems") ArrayList<OrderItemBean> orderItems) throws Exception
{
  ...    
}

Java Bean Code: (getters and setters implied)

public class OrderItemBean
{
  String orderItemId;
  String itemName;
}

I'm not sure where I'm going wrong as I am still learning about Spring.

Roman C
  • 49,761
  • 33
  • 66
  • 176
Matthew
  • 8,183
  • 10
  • 37
  • 65
  • Try the solution described here: http://stackoverflow.com/questions/890250/better-way-for-dynamic-forms-with-spring – gouki Jan 11 '13 at 09:11

1 Answers1

1

I always use declaration params via interface.

try change ArrayList -> List

also be sure that your OrderItemBean declarate with @XmlRootElement annotation and under context.

iMysak
  • 2,170
  • 1
  • 22
  • 35