PDA

View Full Version : سوال: delete a record in jsp page



zha.aye
پنج شنبه 22 بهمن 1388, 18:54 عصر
با سلام
اين برنامه يك دفترچه تلفن ساده هست كه يك شخص را مي توان به آن اضافه و يا از آن حذف كرد من قسمت اضافه شدنش رو نوشتم ولي نميدونم چطور بايد حذفش رو بنويسم! مي خوام با چك زدن هر كدوم از افراد بعد از فشار دادن دكمه delete اون ركورد حذف بشه ممكنه منو راهنمايي كنيد؟


<%@ page language="java" import="java.util.*"
pageEncoding="windows-1256"%>
<%@page import="bo.phoneBook.PhoneBook"%>
<%@page import="struts.form.phoneBook.phoneBookForm"%>
<%@page import="struts.action.phoneBook.phoneBookAction"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<% List<PhoneBook> phoneBooks = (List<PhoneBook>) request
.getAttribute("phoneBook");
Iterator<PhoneBook> phoneBooksIterator = null;
if(phoneBooks != null)
phoneBooksIterator = phoneBooks.iterator();%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<base href="<%=basePath%>">

<title>phoneBook</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My phoneBook</title>
<%PhoneBook b=new PhoneBook();%>
</head>
<body>
<h1><strong>
<label>
<label>My phoneBook</label>
</label>&nbsp;</strong></h1>
<html:form action="/phoneBook.do?method=insertPerson" onsubmit="return validatPhoneBookForm(this);" >
<p>Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="name" id="td1" value="<%b.getName(); %>" />
</p>
<p>Number:&nbsp;&nbsp;&nbsp;
<label>
<input type="text" name="number" id="td2" value="<%b.getNumber(); %>"/>
</label>
</p>
<p>Id:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<label>
<input type="text" name="id" id="td3" value="<%b.getId(); %>"/>
</label>
</p>
<p>Address:&nbsp;&nbsp;
<label>
<input type="text" name="address" id="td4" value="<%b.getAddress();%>"/>
</label>
</p>
<p>
<label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" name="B1" id="B1" value="Add" />
<input type="button" name="B1" id="B1" value="delete" />
</label>
<label>
</label>
</p>
<table width="867" border="1" height="83">
<thead>
<tr>
<th>selected</th>
<th>Address</th>
<th>Number</th>
<th>Name</th>
<th>Id</th>
</tr>
</thead>
<tbody>
<%if(phoneBooksIterator != null){
while(phoneBooksIterator.hasNext()){
PhoneBook temp = phoneBooksIterator.next(); %>
<tr>
<td>
<input type="checkbox" name="checkbox" id="checkbox" >
</td>
<td><%=temp.getAddress() %></td>
<td><%=temp.getNumber() %></td>
<td><%=temp.getName() %></td>
<td><%=temp.getId() %></td>
<%} }%>
</tr>
</tbody>
</table>
</html:form>
</body>
</html>