This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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).
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.