2

I have a form with multiple rows, each row having some editable fields which are mapped to the property of the model class through form input path and a submit(edit) button.

Now, the problem is while submission, I am not able to dynamically append some id to the path to identify the submitted record and get its values in the controller. This is required because every form input path is having same name in each row.

public class FormBean {
    Integer record id;
    Integer amt1;
    Integer am2;
}

and form has multiple rows, each row is mapped to some properties of form bean like

<form:input path = amt1>

Is there any way to identify the submitted record(the editable fields) based on id and edit the values.

Can someone please help me..

rishal
  • 3,230
  • 3
  • 22
  • 29
user2971387
  • 109
  • 1
  • 3
  • 11

1 Answers1

0

I found this link to be great in learning about multi row form using SPring MVC.. http://viralpatel.net/blogs/spring-mvc-multi-row-submit-java-list/

In your case I feel that you need a 'Amount' bean with id, amt1 and amt2 and a 'AmountForm' class which gets and sets a list/map of 'Amount' objects (call this list as amounts).

Then in your form page you would do: <form:form action="..." modelAttribute="amountForm">

and to store each entry in its corresponding map you can use <input name="amounts[0].amt1" value="1" /> or <input name="amounts[your_record_number].your_property" value="your_value" />

Thanks and All the best

Sai
  • 461
  • 7
  • 25