Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 17th, 2003, 04:49 AM
Registered User
 
Join Date: Sep 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to delete a row when click delete hyperlink

hI,

Iam pasting my code below.My problem isi retrieve rows from database and display them in jsp page in rows.For each row there is delete hyperlink.Now when i click that link i should only delete the row corresponding to that delete link temporarily but it should not delete the row from database now.It should only delete the row from database when i click the save button.How can i do this can any one give some code.

thanks
naveen
gudipallyn@yahoo.com

<%@ page language="java" import="Utils.*,java.sql.*,SQLCon.ConnectionPool,j ava.util.Vector,java.util.StringTokenizer" %>


<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Item Details</title>
<script>
function submitPage()
{
document.details.action = "itemdetails.jsp" ;
document.details.submit();
}

</script>
</head>

<body>
<form name="details" action="itemdetails.jsp" method="post">
<%

ConnectionPool pool;
Connection con = null;
Statement st;
ResultSet rs =null;

%>
<table border="0" cellpadding="0" cellspacing="0" width="328">
<tr>
<td width="323" colspan="4"><b>Reference No :</b> <input type="text" name="txt_refno" size="14">
<input type="submit" value="search" name="search" ></td>
</tr>
<tr>
<td width="81" bgcolor="#000099"><b>Item Code</b></td>
<td width="81" bgcolor="#000099"><b>Item No</b></td>
<td width="81" bgcolor="#000099"><b>Amount </b></td>
<td width="80" bgcolor="#000099"> </td>
</tr>
<%
pool= new ConnectionPool();
Utils utils = new Utils();
double total =0.00;
String search =utils.returnString(request.getParameter("search") );

if(search.equals("search"))
{
try
{



String ref_no =utils.returnString(request.getParameter("txt_refn o"));
String strSQL="select * from ref_table where refno='" + ref_no + "' ";

con = pool.getConnection();
st=con.createStatement();
rs = st.executeQuery(strSQL);
while(rs.next())
{
String itemcode=rs.getString(2);
int item_no=rs.getInt(3);
double amount= rs.getDouble(4);
total= total + amount;





%>
<tr>
<td width="81"><input type=hidden name=hitem value=<%=itemcode%>><%=itemcode%></td>
<td width="81"><input type=hidden name=hitemno value=<%=item_no%>><%=item_no%></td>
<td width="81"><input type=hidden name=hamount value=<%=amount%>><%=amount%></td>
<td width="80"><a href="">delete</a></td>
</tr>
<%
}

}catch(Exception e){}

finally {
if (con != null) pool.returnConnection(con);
}
}

%>
<tr>
<td width="323" colspan="4">
<p align="right"><b>Total:</b><input type="text" name="txt_total" size="10" value="<%=total%>"></td>
</tr>
<tr>
<td width="323" colspan="4">
<input type="button" value="save" name="save"></td>
</tr>
</table>
</form>
</body>

</html>



Reply With Quote
  #2 (permalink)  
Old August 16th, 2004, 01:29 AM
Authorized User
 
Join Date: Aug 2004
Location: cluj, romania, Romania.
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to olupas
Default

HI,
Every time when you click the delete button,you should update a list
of deleted rows in the session.

Collection list=new LinkedList();//the list of selected rows
list.add(PK|row identifier);//add the row in the list
session.setAttribute("DeletedRows",list);//finnaly delete the rows
And finally you should delete the rows when you click save.

PS:Embedded java code in the JSP page is not the "nice".
   you should use MVC (like Struts ) http://struts.apache.org/


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGridView - how to delete Row AccessAasif@aol.com C# 2005 0 November 25th, 2007 05:43 AM
Help: Right-click to delete in a datagrid nabrusim VB.NET 2002/2003 Basics 1 November 4th, 2007 11:10 AM
Accept and Delete a row in DataGrid vijay_83 ASP.NET 1.0 and 1.1 Basics 2 September 19th, 2006 12:15 PM
In datagrid when checkbox true delete in btn click ashish2001mca ASP.NET Espanol 1 January 9th, 2006 07:45 AM
Confirm delete row in datagrid rajanikrishna General .NET 3 December 8th, 2004 08:27 PM



All times are GMT -4. The time now is 10:42 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.