Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

get data from html tables and send it to controller/servlet

 
Prasad Krishnegowda
Ranch Hand
Posts: 667
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
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?
 
Mahesh Panchananam
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please mention the techology you are using

e.g: struts/spring/jsf or simple sevlet programming so that I can help you better.

Rgds
Mahesh PS
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Cheers,
Raj.
 
Dieter Quickfend
Bartender
Posts: 543
4
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, you've implemented dynamics rows, then I bet you've got some general id template, no?

For example:

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).
 
Prasad Krishnegowda
Ranch Hand
Posts: 667
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
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.
 
Dieter Quickfend
Bartender
Posts: 543
4
Java Netbeans IDE Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mahesh Panchananam
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
2. Do not try to manage list of too many records in javascript, if so the browser will get hung & throws "Script Error"

Rgds
Mahesh PS
 
Prasad Krishnegowda
Ranch Hand
Posts: 667
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dieter and Mahesh, will try that and let you people know..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic