Currently we have requirement like, based on the user input(i.e integer, valid from 1-4000) the rows in the table will be constructed, these rows contain three fields, where user will be able to type their input for these fields. Now, i have implemented dynamic rows in table, and user is able to type their data also in these rows. Now, what i want is to get all the values the user entered in each row in my controller class. If the rows were less, like 10, i would have got each row values based on id's, but since it can go up to 4000, I feel that's not a good way to do. Can anyone please give me an idea on how to do these?
From what I understand you are creating dynamic input fields, am I correct?
You can associate hidden fields with each row which indicates whether the row has been modified and/or is new. The Db insert/update can can then be decided based on this field.
If you want to limit the data send to the server then pagination could be an option.
I can think of another option of using Ajax for insert/update per row.
So, you've implemented dynamics rows, then I bet you've got some general id template, no?
If you identified the fields as field1row1, field2row1, field1row2, field2row2, field1row3, field2row3, etcetera, you can easily check the amount of rows generated and loop a request.getParameter("field"+i+"row"+j).
Oracle Certified Professional: Java SE 6 Programmer
Oracle Certified Expert: Java EE 6 Web Component Developer
Oracle Certified Expert: Java EE 6 Enterprise JavaBeans Developer
Thanks everyone for the responses..
@Mahesh: I am using Spring.
@Raj: there is no concept of update, everything will be new row only here..
@Deter: Yes, i have created dynamic rows, and associated them with the id. i can do request.getParameter, but the problem is say i have 400 rows, then i have to make 4000*3 request.getParameter, even though it will be in loop, i think, its not a good idea.
Joined: Aug 06, 2010
you can go request.getParameterMap() to get them all at once.
I try not to assume too much about performance. Sometimes, what seems obvious is dead wrong.
Joined: Jun 30, 2011
Yes..! I agree with the Dieter's approach to get the map from the HTML page.
My suggestion is : use pagination or smart fetch, instead of displaying or editing all the rows.
1. Limit the number of rows in each page to 10 or 15.