posts - 403, comments - 310, trackbacks - 0, articles - 7
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          05 Web Project3 (2)

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

          2. 循環<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 標簽庫
          這東東真不錯,支持奇偶數行css分離、自動換頁等功能。
          a) <display:table name="test" />
          這樣一行代碼就能自動列出test內的所有屬性了。
          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) 創建簡單的動態鏈接
          <display:column property="email" href="details.jsp" paramId="action" paramName="testparam" paramScope="request" />
          這樣只能產生details?action=xx的鏈接

          d) 自定義動態鏈接
          寫一個類,繼承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中聲明這個Decorator
          <display:table name="policies" id="PolicyList" decorator="util.Decorator">
          增加相應的列
          <display:column title="Edit" property="editLink"/>
          e) 生成的html代碼中奇偶數行的類分別為.odd和.even,在CSS中就能區分它們了。
          f) 分頁
          display:table 中加個屬性pagesize="10"即可,不過覺得這部分還是在數據庫中解決比較高效。
          g) 排序
          列中的對象要實現Comparable接口,沒有的話可以使用Decorator
          display:table 中的屬性
          defaultsort="1"   默認以第一列為主鍵排序
          defaultorder="descending"  遞減
          也可以在display:column中增加屬性sortable="true" headerClass="sortable"
          官方給出的sample中的那個sortable列表頭很漂亮,有兩個小按鈕選擇排序方式。
          主站蜘蛛池模板: 土默特左旗| 靖宇县| 安塞县| 永兴县| 黄冈市| 昆明市| 上饶县| 肇州县| 东明县| 兰溪市| 万宁市| 怀安县| 全椒县| 台州市| 黔西| 阜新| 遂平县| 即墨市| 云龙县| 陆丰市| 长兴县| 班玛县| 滨海县| 涿州市| 兴文县| 广饶县| 铜梁县| 贵溪市| 敦化市| 乐昌市| 香港 | 吴桥县| 麟游县| 大田县| 呈贡县| 乐都县| 晴隆县| 革吉县| 临沧市| 永胜县| 鹤壁市|