When checkout button is going to submit the modified table to another servlet, how this servlet is going to read the modified table ? Simply put, how a servlet can read (row,cell) of a html table ?
An HTML table can't be submitted to a servlet. What you can submit is an HTML form; so for any write or delete operations you need to construct an HTML form that submits all relevant data to the servlet (maybe the ID of the data to be deleted).
Ping & DNS - updated with new look and Ping home screen widget
Joined: Nov 11, 2008
Can I do something like this to achieve, as I described in my first mail ?
If someone could please review this idea and post the syntactical summary -do appreciate very much. Thanks.
I don't consider making things complex.... Your's is a simple case and it has a very simple solution:
As you said you populate the table using a servlet, I assume that you have the data, more over you are not entering or modifying the data in table but simply "deleting the rows".
If you need I can paste the code for you, but its really simple and I think you can do it yourself.
You can use the following steps:
1. In the servlet that populates the table, along with the rows insert a hidden field "id" and set its "value" to a unique key to identify the row. (eg: you can use the primary key if each row represents each record in db)
2. You can "Delete the rows" from the table using a simple "Java Sript function" when you click the delete row button.
3. The entire table should be inside <form> and when you click the submit button, all the "hidden fields" will be submitted which represents the rows that are not deleted.
4. Using the ServletRequest's getParameterValues() or if it is Jsp, you can use EL implicit object 'paramValues["id"]' to retrieve the array of submitted "id"'s.
Now, as you got the keys, you can identify which rows are submitted.
As simple as that!
Joined: Nov 11, 2008
Thanks everybody for eloquent suggestions. But I adopeted William's getParameterMap() approach - thinking of long term usage of this application.