Solved

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

Posted on 2003-11-19
5
278 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While it may be true that the internet is a place of possibilities, it is also a hostile environment lurking with many dangers. By clicking on the wrong link, trusting the wrong person or using a weak password, you are virtually inviting hackers to …
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

763 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