漁人碼頭

          天行健,君子以自強不息。地勢坤,君子以厚德載物。
          posts - 12, comments - 16, trackbacks - 0, articles - 43
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          displayTag學習摘要(轉)

          Posted on 2008-02-23 09:06 Fisher 閱讀(339) 評論(0)  編輯  收藏 所屬分類: 開源組件
          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方法:
          public String getLink1()       
          {                
              ListObject lObject
          = (ListObject)getCurrentRowObject();
              
          int lIndex= getListIndex();
              
          return  lObject.getId();
          }

           
          標簽:
          <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中封裝的對象的屬性要實現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轉為空白 

          Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1500611

          主站蜘蛛池模板: 那坡县| 石景山区| 贺兰县| 页游| 西平县| 思茅市| 体育| 新建县| 林州市| 西贡区| 陇川县| 堆龙德庆县| 嘉鱼县| 辽宁省| 崇文区| 小金县| 苏州市| 鄂托克旗| 旬邑县| 潢川县| 河北省| 元谋县| 永吉县| 孟州市| 平定县| 汝阳县| 清河县| 张家港市| 珠海市| 达孜县| 青冈县| 江永县| 新田县| 新和县| 凉山| 乃东县| 工布江达县| 白水县| 横山县| 邵阳县| 常宁市|