分享java带来的快乐

我喜欢java新东西

displaytag 改造后能一行显示多列,输出字段非常方便,还可以按需查询数据,而且原有功能不丢失

<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="display" uri="displaytag"%>
<%@ taglib prefix="linktone" uri="linktonetag"%>
<%@ page
 import="com.lee.orderdish.util.ParamUtils,org.displaytag.sample.*,java.util.*,org.displaytag.tags.TableTag,com.linktone.taglib.displaytagpage.PageInfo"%>
<html>
<head>
<title>Simple jsp page</title>
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/style.css" type="text/css" />
</head>

<body>
<%int currentPage = ParamUtils.getIntParameter(request,
     "currentPage", 1);

   TestList list = new TestList(100, false);
   PageInfo pageInfo = new PageInfo();
   pageInfo.setMaxCount(100);
   pageInfo.setPageSize(6);
   pageInfo.setCurrentPage(currentPage);
   int startindex = pageInfo.getStart() - 1;
   int endindex = pageInfo.getEnd() <= list.size() ? pageInfo.getEnd()
     : list.size();
   out.println("startIndex:" + startindex);
   out.println("endIndex:" + endindex);
   java.util.List subList = list.subList(startindex, endindex);

   request.setAttribute("test", subList);
   int type = 1;
   int maxsize = 24;

   %>
<center>
<linktone:displaywrap uid="aa" name="test" pagesize="6"
 maxsize="<%=maxsize%>" append="age=34&type=1" requestURI="displaytagdemo.jsp" />
 
<display:table uid="currentElement" name="test" pagesize="6"
 width="100%" class="Mars">
 <display:column property="id" nowrap="true" title="ID" align="left" />
 <display:column property="name" nowrap="true" title="名称" align="left" />
 <display:column nowrap="true" title="编辑" align="left">
  <a
   href="javascript:alert('<%=((ListObject)currentElement).getId() %>')">编辑</a>
 </display:column>
</display:table>
<display:table border="1" name="test" pagesize="6"
 rowsize="2" width="100%" class="Mars">
 <table width="100%">
  <tr>
   <td>{id}</td>
  </tr>
  <tr>
   <td>{naMe}</td>
  </tr>
  <tr>
   <td><a href="javascript:alert('{naMe}')">编辑</a></td>
  </tr>
 </table>
</display:table>
<linktone:displaywrap uid="aa" name="test" pagesize="6"
 maxsize="<%=maxsize%>" append="age=34&type=1" requestURI="displaytagdemo.jsp" />
</center>
</body>
</html>
该文件源代码在:http://www.blogjava.net/Files/lyjjq/displaytagdemo.rar
用到的包和配置文件在:http://www.blogjava.net/Files/lyjjq/lib.rar

posted on 2006-03-31 10:03 强强 阅读(996) 评论(0)  编辑  收藏 所属分类: Java


只有注册用户登录后才能发表评论。


网站导航: