• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to update the database after multiple add and delete

 
akash sangwan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all Hello to everyone,

I am facing a problem in my project ,Please do help me as I have already tried 5 days on it......

I have a screen which add ,delete 2 fields in a Table .But I want that it should not to modification until I hit Submit button .It means it should show:

Column1 Column2

12 89
67 78
67 89
67 89

on JSP whenever I do add delete it should not do it in database but keep the values in memory + show it on screen .Until I hit Sumbit button.


Please help me ............
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Akash,

You need to look at how to delete the rows from HTML without posting the request to the server. Look at DHTML api's.

Let's say you add/delete a row, then you must save the information which row is added/deleted and post the data to the server and make JDBC calls.

In short
- Use DHTML DOM api to manipulate the table rows
- Store the deleted row/added row information in the form. Use can use flag to identity if the row is unaltered,deleted,new.
- Post the entire table
- Process the table data in the JSP with JDBC calls.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could also build a object with methods for editing, adding, deleting, commiting, etc.. and bind it to session.
 
akash sangwan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am still not getting , I never used DOM .
I tried to use array List to store values in but how to delete values .I am confused .Please help??
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTML elements (with id attributes) can be manipulated using DOM 1.0 api's. Search this site at HTML/Javascript to find out how to delete a row or add a new row or use this link http://www.coderanch.com/t/117184/HTML-JavaScript/Move-data-one-table-another
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First figure out where you want to do this.
The two general approaches are to...

1.) Maintain the state of the user's changes on the server by storing an object in the user's session.

2.) Do everything from within the browser using DHTML.

If you feel overwhelmed by either, then maybe you should step back a bit from this project and spend some time with a few books on JSP/Servlets or HTML/Javascript. Follow the examples in the books or web tutorials until you feel that you really understand the technology.

Then... when you come back to this project, you'll be equipped not only with the knowledge to get something working but enough of an understanding about both the technology and your domain set to insure that you build it in a way that is best for you or your client.
[ January 05, 2006: Message edited by: Ben Souther ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!