Using script :
<!-- Do Delete -->
<script language="JavaScript">
function doDeleteData(primaryKey) {
alert("Delete1");
window.location = "adminTcDoDeleteLoad.do?primaryKey="+primaryKey;
alert("Delete2");
}
</script>
jsp page:
<% int k=0; %>
<s:iterator value="teacherTypeList" status="status">
<% k+=1;%>
<tr >
<td width="2%"><s:property value='#status.count'/></td>
<td width="2%"><s:property value='tech_general_info_id'/></td>
<td width="4%" style="text-align:left;"><s:property value='tech_name'/></td>
<td id="recordId<%=k %>" width="15%"><s:property value='desig_id'/></td>
<td width="2%"> </td>
<td width="4%"> </td>
<td > </td>
<td width="15%">
<span><a href="adminTcEditLadmin.do">Edit</a></span>
<span><a href="#">Delete</a></span>
</td>
<td ><a href="#" onclick="doEditData('recordId<%=k %>','<s:property value='tech_general_info_id'/>','<s:property value='tech_name'/>','<s:property value='desig_id'/>');" style="font-family:Arial; font-size:12px; font-weight:bold; color:#000;">DoEdit</a></td>
<td ><a href="#" onclick="doDeleteData('<s:property value='tech_general_info_id'/>');" >DoDelete</a></td>
</tr>
</s:iterator>
java action class :
//Do Delete
private String primaryKey;
public String adminTcDoDelete(){
TeacherListSql teacherListSql = new TeacherListSql();
teacherListSql.getDeleteTable(primaryKey);
teacherList();
return "adminTcDoDelete";
}
sql class file:
//Delete statement
public void getDeleteTable(String priId){
System.out.println("kaniz");
boolean fg = true;
con = dbc.connectDB();
if (con == null) {
fg = false;
}
if (fg) {
try {
st = con.createStatement();
//query = "insert into fn_bank(BANK_ID,BANK_NAME,ENTRY_TIMESTAMP,COMPANY_NO) values ('"+bank_id+"','"+bankName+"',sysdate,'1')";
//queryUpdate = "update tech_general_info set TECH_NAME = '"+teacherName+"',DESIGNATION_NAME = '"+teacherDesig+"' where TECH_GENERAL_INFO_ID='"+teachGeneralId+"'";
String queryDelete = "delete from tech_general_info where TECH_GENERAL_INFO_ID='"+priId+"'";
System.out.println("QueryDelete" + queryDelete);
//st.execute(query);//It is use for insert Query
st.execute(queryDelete);
} catch (SQLException sq) {
sq.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
}
con.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
//return "getBankInfoPageReturn"; //Remember DELETE query not Return;.Only select query return List.
}
<!-- Do Delete -->
<script language="JavaScript">
function doDeleteData(primaryKey) {
alert("Delete1");
window.location = "adminTcDoDeleteLoad.do?primaryKey="+primaryKey;
alert("Delete2");
}
</script>
jsp page:
<% int k=0; %>
<s:iterator value="teacherTypeList" status="status">
<% k+=1;%>
<tr >
<td width="2%"><s:property value='#status.count'/></td>
<td width="2%"><s:property value='tech_general_info_id'/></td>
<td width="4%" style="text-align:left;"><s:property value='tech_name'/></td>
<td id="recordId<%=k %>" width="15%"><s:property value='desig_id'/></td>
<td width="2%"> </td>
<td width="4%"> </td>
<td > </td>
<td width="15%">
<span><a href="adminTcEditLadmin.do">Edit</a></span>
<span><a href="#">Delete</a></span>
</td>
<td ><a href="#" onclick="doEditData('recordId<%=k %>','<s:property value='tech_general_info_id'/>','<s:property value='tech_name'/>','<s:property value='desig_id'/>');" style="font-family:Arial; font-size:12px; font-weight:bold; color:#000;">DoEdit</a></td>
<td ><a href="#" onclick="doDeleteData('<s:property value='tech_general_info_id'/>');" >DoDelete</a></td>
</tr>
</s:iterator>
java action class :
//Do Delete
private String primaryKey;
public String adminTcDoDelete(){
TeacherListSql teacherListSql = new TeacherListSql();
teacherListSql.getDeleteTable(primaryKey);
teacherList();
return "adminTcDoDelete";
}
sql class file:
//Delete statement
public void getDeleteTable(String priId){
System.out.println("kaniz");
boolean fg = true;
con = dbc.connectDB();
if (con == null) {
fg = false;
}
if (fg) {
try {
st = con.createStatement();
//query = "insert into fn_bank(BANK_ID,BANK_NAME,ENTRY_TIMESTAMP,COMPANY_NO) values ('"+bank_id+"','"+bankName+"',sysdate,'1')";
//queryUpdate = "update tech_general_info set TECH_NAME = '"+teacherName+"',DESIGNATION_NAME = '"+teacherDesig+"' where TECH_GENERAL_INFO_ID='"+teachGeneralId+"'";
String queryDelete = "delete from tech_general_info where TECH_GENERAL_INFO_ID='"+priId+"'";
System.out.println("QueryDelete" + queryDelete);
//st.execute(query);//It is use for insert Query
st.execute(queryDelete);
} catch (SQLException sq) {
sq.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
}
con.close();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
//return "getBankInfoPageReturn"; //Remember DELETE query not Return;.Only select query return List.
}
No comments:
Post a Comment