aspose file tools*
The moose likes JSP and the fly likes get data from html tables and send it to controller/servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "get data from html tables and send it to controller/servlet" Watch "get data from html tables and send it to controller/servlet" New topic
Author

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

Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 537

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

Joined: Jun 30, 2011
Posts: 18
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

Joined: Mar 02, 2005
Posts: 443
    
    1

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

Joined: Aug 06, 2010
Posts: 543
    
    4

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).


Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 537

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

Joined: Aug 06, 2010
Posts: 543
    
    4

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

Joined: Jun 30, 2011
Posts: 18
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

Joined: Apr 25, 2010
Posts: 537

Thanks Dieter and Mahesh, will try that and let you people know..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: get data from html tables and send it to controller/servlet