1.tableTag中name屬性:值默認(rèn)作用域:request
<display:table name="accList">
如果作用域?yàn)閟ession,則<display:table name="sessionScope.accList">
tableTag中指定ID屬性會(huì)把該對(duì)象加入到pageContext對(duì)象中去。如ID="test"
<%int cate=((Role)pageContext.getAttribute("test")).getCategory();%>
生成表格的序列號(hào) 例如:<display:table id="row" name="mylist">
<display:column title="序列號(hào)"><%=pageContext.getAttribute("row_rowNum")%></display:column>
如行號(hào):row_rowNum <c:out value="${row_rowNum}"/>
firstName:row.firstName <c:out value="${row.firstName}"/>
lastName: row.lastName 全部由ID來取得
2.限制頁面顯示的結(jié)果集數(shù)1)全部<display:table name="accList" class="its" id="test">
2)頭5個(gè)<display:table name="accList" class="its" id="test" length="5">
3)從第二個(gè)開始,顯示下5個(gè)<display:table name="accList" class="its" id="test" offset="2" length="5">
3.包裝器decorators,有行包裝器(必須繼承TableDecorator)和列包裝器(必須實(shí)現(xiàn)ColumnDecorator) 在tableTag中顯示list時(shí),decorators中的方法會(huì)在list前調(diào)用,如果decorators實(shí)現(xiàn)類中有相關(guān)的getXXX()方法時(shí),調(diào)用此方法,如果沒有,則直接調(diào)用list
在columnTag中顯示value時(shí),decorators中的方法會(huì)先調(diào)用,(應(yīng)該重用)
4.傳遞參數(shù),有兩種方式, 一。struts方式:有以下幾個(gè)屬性
1)href 基本的超連接
2)paramId 添加到url上的參數(shù)名
<display:column property="status" href="details.jsp" paramId="id" paramProperty="id" />
3)paramName 傳遞容器內(nèi)的其它bean當(dāng)作參數(shù) 如:request.setAttribute("testparam", "sendamail");
<display:column property="email" href="details.jsp" paramId="action" paramName="testparam" paramScope="request" />
4)paramScope 指定bean的作用域
二。decorators方式
類Wrapper方法:
public String getLink1()
{
ListObject lObject= (ListObject)getCurrentRowObject();
int lIndex= getListIndex();
return "<a href="details.jsp?index=" + lIndex + "">" + lObject.getId() + "</a>";
}
標(biāo)簽:
<display:table name="sessionScope.details" decorator="org.displaytag.sample.Wrapper" >
<display:column property="link1" title="ID" />
<display:column property="email" />
</display:table>
5.分頁 指定屬性:pagesize="10" 每頁顯示10條記錄
6.排序1)在list中封裝的對(duì)象的屬性要實(shí)現(xiàn)Comparable接口,(一般均實(shí)現(xiàn)了)
2) 在columnTag中指定sortable="true"
可指定默認(rèn)排序的列 defaultsort="1" 數(shù)值為第幾列默認(rèn)排序 defaultorder="descending" 指定默認(rèn)為降序
7.導(dǎo)出 支持下列格式:'html', 'xml', 'csv', and 'excel'. 屬性:export="true",注意導(dǎo)出無效,當(dāng)使用jsp:include or the RequestDispatcher
<display:column media="csv excel" title="URL" property="url"/>
指定該url屬性值只能在csv、excel中導(dǎo)出
需要指定export filter.
8.更改默認(rèn)設(shè)置 1)通過<display:setProperty name=... value=...> 標(biāo)簽,可以覆蓋一些默認(rèn)設(shè)置
2)創(chuàng)建displaytag.properties文件,所有時(shí)區(qū)共用,建中文編碼則創(chuàng)建displaytag_zh_cn.properties,放到類路徑下,jar包內(nèi)共有兩個(gè)默認(rèn)的屬性文件TableTag.properties,message.properties
9其它 1)當(dāng)多個(gè)表在一頁顯示時(shí),每個(gè)表都想要有分頁、排序、導(dǎo)出等功能時(shí),只需為每個(gè)table指定一個(gè)不同的ID即可。
2)增加表頭<display:caption>角色管理</display:caption>
3)增加表尾 <display:footer><tr><td colspan="6" align="center" >國瑞數(shù)碼版權(quán)所有</td></tr></display:footer>
4)http和email自動(dòng)鏈接功能,指定autolink="true"
5)指定一列顯示的最大長度,避免太長把表格變形 maxLength="10" style="whitespace: nowrap;"
6)當(dāng)列的值為null,使用nulls="false"屬性把null轉(zhuǎn)為空白
posted on 2005-12-14 10:55
似水流年 閱讀(275)
評(píng)論(0) 編輯 收藏 所屬分類:
JSP/Servlet