displayTag學習摘要

 1.tableTag中name屬性:值默認作用域:request
<display:table name="accList">
如果作用域爲session,則<display:table name="sessionScope.accList">
tableTag中指定ID屬性會把該對象加入到pageContext對象中去。如ID="test"
<%int cate=((Role)pageContext.getAttribute("test")).getCategory();%>
生成表格的序列號 例如:<display:table id="row" name="mylist">
<display:column title="序列號"><%=pageContext.getAttribute("row_rowNum")%></display:column>
如行號:row_rowNum <c:out value="${row_rowNum}"/>
firstName:row.firstName   <c:out value="${row.firstName}"/>
lastName: row.lastName  全部由ID來取得

2.限制頁面顯示的結果集數
1)全部<display:table name="accList" class="its" id="test">
2)頭5個<display:table name="accList" class="its" id="test" length="5">
3)從第二個開始,顯示下5個<display:table name="accList" class="its" id="test" offset="2" length="5">

3.包裝器decorators,有行包裝器(必須繼承TableDecorator)和列包裝器(必須實現ColumnDecorator)
  在tableTag中顯示list時,decorators中的方法會在list前調用,如果decorators實現類中有相關的getXXX()方法時,調用此方法,如果沒有,則直接調用list
  在columnTag中顯示value時,decorators中的方法會先調用,(應該重用)

4.傳遞參數,有兩種方式,
  一。struts方式:有以下幾個屬性
  1)href 基本的超連接
  2)paramId 添加到url上的參數名
  <display:column property="status" href="details.jsp" paramId="id" paramProperty="id" />
  3)paramName 傳遞容器內的其它bean當作參數 如:request.setAttribute("testparam", "sendamail");
  <display:column property="email" href="details.jsp" paramId="action" paramName="testparam" paramScope="request" />
  4)paramScope 指定bean的作用域
  二。decorators方式
  類Wrapper方法:




標籤:



5.分頁
  指定屬性:pagesize="10" 每頁顯示10條記錄

6.排序
1)在list中封裝的對象的屬性要實現Comparable接口,(一般均實現了)
2) 在columnTag中指定sortable="true"
  可指定默認排序的列 defaultsort="1" 數值爲第幾列默認排序 defaultorder="descending" 指定默認爲降序

7.導出 支持下列格式:'html', 'xml', 'csv', and 'excel'.
  屬性:export="true",注意導出無效,當使用jsp:include or the RequestDispatcher
  <display:column media="csv excel" title="URL" property="url"/>
  指定該url屬性值只能在csv、excel中導出
  需要指定export filter.

8.更改默認設置
  1)通過<display:setProperty name=... value=...> 標籤,可以覆蓋一些默認設置
  2)創建displaytag.properties文件,所有時區共用,建中文編碼則創建displaytag_zh_cn.properties,放到類路徑下,jar包內共有兩個默認的屬性文件TableTag.properties,message.properties

9其它
  1)當多個表在一頁顯示時,每個表都想要有分頁、排序、導出等功能時,只需爲每個table指定一個不同的ID即可。
  2)增加表頭<display:caption>角色管理</display:caption>
  3)增加表尾  <display:footer><tr><td colspan="6" align="center" >國瑞數碼版權所有</td></tr></display:footer>
  4)http和email自動鏈接功能,指定autolink="true"
  5)指定一列顯示的最大長度,避免太長把表格變形 maxLength="10" style="whitespace: nowrap;"
  6)當列的值爲null,使用nulls="false"屬性把null轉爲空白
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章