posts - 403, comments - 310, trackbacks - 0, articles - 7
            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          05 Web Project3 (2)

          Posted on 2007-05-02 13:35 ZelluX 閱讀(521) 評(píng)論(0)  編輯  收藏 所屬分類: OOP
          1. CSS控制input標(biāo)簽的風(fēng)格有點(diǎn)麻煩,google到了一種在css中使用三元判斷語(yǔ)句的方法:
          1input {
          2    width: expression(this.type!="submit"?'150px':'');
          3    height: 23px;
          4}

          2. 循環(huán)<c:forEach var="i" begin="1" end="${pages}">
           
          3. 分支
          1<c:choose>
          2  <c:when test="${boolean1}"></c:when>
          3  <c:when test="${boolean2}"></c:when>
          4  <c:otherwise></c:otherwise>
          5</c:choose>


          4. DisplayTag 標(biāo)簽庫(kù)
          這東東真不錯(cuò),支持奇偶數(shù)行css分離、自動(dòng)換頁(yè)等功能。
          a) <display:table name="test" />
          這樣一行代碼就能自動(dòng)列出test內(nèi)的所有屬性了。
          b) 如果要只列出指定的列,可以使用

          <display:table name="test">
             
          <display:column property="id" title="ID" />
             
          <display:column property="name" />
             
          <display:column property="email" />
             
          <display:column property="status" />
             
          <display:column property="description" title="Comments"/>
          </display:table>

          c) 指定某一列的樣式:<display:column property="id" title="ID" class="idcol"/>
          d) 創(chuàng)建簡(jiǎn)單的動(dòng)態(tài)鏈接
          <display:column property="email" href="details.jsp" paramId="action" paramName="testparam" paramScope="request" />
          這樣只能產(chǎn)生details?action=xx的鏈接

          d) 自定義動(dòng)態(tài)鏈接
          寫一個(gè)類,繼承org.displaytag.decorator.TableDecorator
          package util;

          import org.displaytag.decorator.TableDecorator;

          public class Decorator extends TableDecorator {
            
          public String getEditLink() {
              beans.Policy p 
          = (beans.Policy)getCurrentRowObject();
              
          int pId = p.getId();
              
          return "<a href=\"servlet/editItem?id=" + pId + "\">@</a>";  
            }

          }
          然后在jsp中聲明這個(gè)Decorator
          <display:table name="policies" id="PolicyList" decorator="util.Decorator">
          增加相應(yīng)的列
          <display:column title="Edit" property="editLink"/>
          e) 生成的html代碼中奇偶數(shù)行的類分別為.odd和.even,在CSS中就能區(qū)分它們了。
          f) 分頁(yè)
          display:table 中加個(gè)屬性pagesize="10"即可,不過(guò)覺得這部分還是在數(shù)據(jù)庫(kù)中解決比較高效。
          g) 排序
          列中的對(duì)象要實(shí)現(xiàn)Comparable接口,沒(méi)有的話可以使用Decorator
          display:table 中的屬性
          defaultsort="1"   默認(rèn)以第一列為主鍵排序
          defaultorder="descending"  遞減
          也可以在display:column中增加屬性sortable="true" headerClass="sortable"
          官方給出的sample中的那個(gè)sortable列表頭很漂亮,有兩個(gè)小按鈕選擇排序方式。
          主站蜘蛛池模板: 古交市| 普安县| 北海市| 临西县| 多伦县| 奈曼旗| 龙门县| 繁峙县| 九龙县| 香河县| 四会市| 涿州市| 监利县| 临沧市| 定西市| 镇沅| 昌乐县| 江西省| 盐津县| 孝感市| 安庆市| 新营市| 梧州市| 安多县| 慈利县| 松潘县| 乌兰浩特市| 咸丰县| 盈江县| 新泰市| 慈利县| 临清市| 延吉市| 高阳县| 德令哈市| 政和县| 海晏县| 龙胜| 滦平县| 牙克石市| 荥经县|