Solved

How to Remove a particular record in a JSP Page (without deleting it from the Database) ...

Posted on 2003-11-19
5
272 Views
Last Modified: 2010-04-01
Hello Experts,

 I have a table " company " in my database with fields as shown:

company name               address                  phone number             Remove

  ABCDEFG                 12, XX , YYY.                   11111111                remove
  QWERTZ                  32, FF, GFE.                    44444444                remove

and so on............(upto 2000 companies displaying in 50 Pages...i.e. Records per page - 40)

I am able to connect to my 'Postgresql database' and display all the records in my JSP Page.

Now, When i click the ' remove ' button, the JSP page must be reloaded in such a way that the 'Selected Company' is removed from that Page, but not from the database.

Hope you understand the problem. If not, please tell me...I'll post my Coding part...

Expecting your earlier reply,
Regards ,
Jagdeesh
0
Comment
Question by:jaggybala2
5 Comments
 
LVL 15

Assisted Solution

by:jimmack
jimmack earned 50 total points
ID: 9777421
One quick solution would be to store the removed elements in an ArrayList.

When the page is first loaded, create a new ArrayList.

When the page is loaded with a company name to be removed, add this to the ArrayList, then when you Iterate through the ResultSet to create the table, for each row, use the contains() method of the ArrayList to see if you have added the company that you are about to display.  If contains() returns true, don't display it.

Store the ArrayList in the session.

Any good?
0
 

Author Comment

by:jaggybala2
ID: 9777577
Thanx for your comment Jimmack...

By the way, at the end of the JSP Page , I have a button named 'EXECUTE ACTIVITIES'...When i click that button, some activities(those activities 'ActivityList.jsp' are included inside the above 'CompanyList.jsp' File) must be inserted into the 'COMPANY TABLE - ACTIVITY FIELD'  ...

When i do like what you have suggested, Is it possible ?

Thanx,
Jagdeesh.
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9777591
Similar thing.  If the data created in the ActivityList.jsp are stored in a session variable, this can be accessed from within the CompanyList.jsp page and the appropriate items included.
0
 
LVL 19

Accepted Solution

by:
Kuldeepchaturvedi earned 100 total points
ID: 9777702
Here is how I would do it...
1. First load the jsp.....
2. create a Hashtable and put it in the session.....
3. Assuming there are only delete/change options that you are allowing users to perform....
4. let them delete/change the rows they want to...
5. at the time this jsp gets submitted back to the server...
6. Pick all the rows and operations and put them in hashtable ..
Hashtable h1= (Hashtable)session.getAttribute("myhash");
h1.put(yourrecordkey, operation);
7. now read the database and put a if condition in it
while(rs.next())
{
if(h1.get(rs.getString("key")!=null)
{
show on grid
}
else
{
do not show...
}
}

8. When user hits the execute activities
9. get the hashtable from session...
10. Start getting the keys and operations from the hashtable and execute them on the database...

end of algorithm.
Hope this helps you
Regards
0
 
LVL 6

Expert Comment

by:jarasa
ID: 9778696
Hi there.
I'm trying to understand why you want to remove a record from the page and not from the table, but I guess the best way you can do is to put a remove_date field in your Company table and use it as a filter so you only show the ones who have no remove_date. If the problem is that diferente users sees diferent companies in their own wallet, then you should make a wallet table where you hold the user->company relationship and then you show only the user companies and you can remove the company from the user without removing the company from the table.
Anyway I guess you should give me more information, but you should analize your situation becose there are many times that is easier to restrict things on the Database instead of doing it by code, and is much cleaner and easier to deal with.
best regards
Javier
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

HOW TO: Upload an ISO image to a VMware datastore for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere Host Client, and checking its MD5 checksum signature is correct.  It's a good idea to compare checksums, because many installat…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now