時光如水

          我心跳動
          posts - 6, comments - 10, trackbacks - 0, articles - 4
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          displayTag學(xué)習(xí)摘要

          Posted on 2005-11-21 17:11 qiqijava 閱讀(773) 評論(1)  編輯  收藏 所屬分類: Tag

          當(dāng)時想要這樣一個標(biāo)簽,能實現(xiàn)分頁、排序、過濾、搜索功能,且頁面比較美觀。先后學(xué)習(xí)了三個比較有名的標(biāo)簽:displayTag、eXtremeComponents、valueList。個人感覺:

          display上手容易,功能簡單,界面漂亮,不過功能比較有限。感覺最不爽的就是在一頁上排好序后,再點擊下一頁后,排序就亂了。而且當(dāng)數(shù)據(jù)量大時,它的排序會有問題

          eXtremeComponents上手容易,操作煩索,界面一般,不過起碼在排序上就沒有displayTag的問題。數(shù)據(jù)量大時,它的排序也會有問題

          valueList我認(rèn)為最強大的標(biāo)簽,需要與spring結(jié)合使用,上手不易,界面漂亮,功能超強。目前沒有發(fā)現(xiàn)任何不爽的地方。

          先貼出display的心得,后續(xù)會貼出其它兩個的心得


                                            displayTag學(xué)習(xí)摘要
          1.tableTag中name屬性:值默認(rèn)作用域: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.限制頁面顯示的結(jié)果集數(shù)
           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)和列包裝器(必須實現(xiàn)ColumnDecorator)
            在tableTag中顯示list時,decorators中的方法會在list前調(diào)用,如果decorators實現(xiàn)類中有相關(guān)的getXXX()方法時,調(diào)用此方法,如果沒有,則直接調(diào)用list
            在columnTag中顯示value時,decorators中的方法會先調(diào)用,(應(yīng)該重用)

          4.傳遞參數(shù),有兩種方式,
            一。struts方式:有以下幾個屬性
            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中封裝的對象的屬性要實現(xiàn)Comparable接口,(一般均實現(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文件,所有時區(qū)共用,建中文編碼則創(chuàng)建displaytag_zh_cn.properties,放到類路徑下,jar包內(nèi)共有兩個默認(rèn)的屬性文件TableTag.properties,message.properties

          9其它
            1)當(dāng)多個表在一頁顯示時,每個表都想要有分頁、排序、導(dǎo)出等功能時,只需為每個table指定一個不同的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自動鏈接功能,指定autolink="true"
            5)指定一列顯示的最大長度,避免太長把表格變形 maxLength="10" style="whitespace: nowrap;"
            6)當(dāng)列的值為null,使用nulls="false"屬性把null轉(zhuǎn)為空白


          評論

          # re: displayTag學(xué)習(xí)摘要  回復(fù)  更多評論   

          2009-06-30 22:40 by 孤寂
          還是不太懂也

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 武清区| 新晃| 信阳市| 玛纳斯县| 离岛区| 江门市| 临沂市| 侯马市| 资源县| 朔州市| 汕头市| 麻阳| 博野县| 光泽县| 太康县| 洛阳市| 淅川县| 东兰县| 商河县| 社旗县| 仙居县| 阿城市| 盘锦市| 东台市| 桦甸市| 华亭县| 大姚县| 老河口市| 双辽市| 深水埗区| 益阳市| 晋城| 贵港市| 榆社县| 若尔盖县| 顺义区| 开封县| 永仁县| 赞皇县| 樟树市| 乳山市|