<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'main.jsp' starting page</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">
    -->
    <link href="css/style.css" rel="stylesheet" type="text/css">
    <script language="javascript" src="script/common.js"></script>
  <script src='dwr/interface/NewsFormDAO.js'></script>
  <script src='dwr/engine.js'></script>
  <script src='dwr/util.js'></script>
    <SCRIPT type="text/javascript">
    var myrowid;
    function add(){
    htmlurl="add_news.html";
	var newwin=window.open(htmlurl,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=1,resizable=0,top=2,width=460,height=400');
	return false;
    }
    
    function modifyMe(row){
    htmlurl="./newsOption.do?method=typeme&newsid="+row.cells[0].innerHTML;
	var newwin=window.open(htmlurl,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=1,resizable=0,top=2,width=460,height=400');
	return false;
    }
    
    function deleteMe(row){
    	//alert(row.cells[0].innerHTML); 
    	myrowid = row.rowIndex;  	
    	NewsFormDAO.deleteNews(row.cells[0].innerHTML,delFun);
    }
    
    function delFun(data){
   	if (data!=0){
   	alert("删除成功");
   	var mytable = document.getElementById("table100");
	mytable.deleteRow(myrowid);
   	}else{
   	alert("删除失败");
   	}
    }
    </SCRIPT>
  </head>
  
  <body>
	<jsp:include page="toolbar.html"/>
	<bean:message key="hello.title"/>
	<TABLE width="100%" id="table100">
	<TR>
	<td class="title1" align="center" nowrap>序号</td>
	<td class="title1" align="center" nowrap>标题</td>
	<td class="title1" align="center" nowrap>添加时间</td>
	<logic:equal name="logonType" value="yes">
	<td class="title1" align="center" nowrap>操作</td>
	</logic:equal>
	</TR>
	<logic:present name="listNews" scope="session">
	<logic:iterate id="mylist" name="listNews" scope="session" type="cn.lingqi.struts.form.NewsForm">
	<tr>
	<td align="center" nowrap><bean:write name="mylist" property="newsId"/></td>
	<td align="center" nowrap><a href="./newsOption.do?method=typenews&newsid=<bean:write name="mylist" property="newsId"/>"><bean:write name="mylist" property="title"/></a></td>
	<td align="center" nowrap><bean:write name="mylist" property="createDate"/></td>
		<logic:equal name="logonType" value="yes">
	<td align="center" nowrap><input type="button" value="编辑" onclick="modifyMe(this.parentNode.parentNode);">
	<input type="button" value="删除" onClick="deleteMe(this.parentNode.parentNode);"></td>
	</logic:equal>
	</tr>
	</logic:iterate>
	</logic:present>
	</TABLE>
	<jsp:include page="page.jsp"/>
  </body>
</html>
