<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-9  評論-2  文章-0  trackbacks-0
    struts2里增加了一個新的UT標簽s:checkboxlist,下面介紹下使用方法。
    s:checkboxlist用于畫面上顯示一組復選框,缺省是橫排輸出,后面將介紹如何修改ftl文件使得它能按任意方式輸出。
    標簽格式:
        <s:checkboxlist name="" list="" listKey="" listValue="" value="" />
        name-定義標簽名,用于接收畫面上選中的復選框,故應與Action里定義的屬性一致,且多為數組;
        list-定義集合變量,用于輸出復選框到畫面上,一般在Action里定義一個List或Map屬性;
        listKey-如果在Action里定義的是一個List,則往往會在List里定義一個Bean,它只有兩個屬性,其中一個(比如id)就在這里設置;
                    如果在Action里定義的是一個Map,則Map的key就在這里設置;
        listValue-如果在Action里定義的是一個List,則往往會在List里定義一個Bean,它只有兩個屬性,另外一個(比如name)就在這里設置;
                      如果在Action里定義的是一個Map,則Map的value就在這里設置;
        value-用于回顯畫面上被選中的復選框,假如畫面有輸入檢查,如果有錯則返回原畫面并顯示出錯信息,這時候就需要使用它。
                 一般把它設成和name一致就可以了。
    注意點:
        為了能正確顯示已被選中的復選框,一定要使得name的數組類型與listKey的類型一致。
        比如,name設成String[] users,則listKey就要設成String id;如果name設成Integer[] users,則listKey就要設成Integer id;
    修改ftl文件改變輸出方式:
        1.搜索struts2-core-xxx.jar,找到checkboxlist.ftl文件,拷貝出來;
        2.在自己的工程的src下新建template.simple包,放置上述文件;
        3.用文本編輯器打開該文件,修改成自己希望輸出的格式,保存,OK;
    例子:
        希望畫面上每3個復選框輸出為一行。
    <#--
    /*
     * $Id: checkboxlist.ftl 804072 2009-08-14 03:16:35Z musachy $
     *
     * Licensed to the Apache Software Foundation (ASF) under one
     * or more contributor license agreements.  See the NOTICE file
     * distributed with this work for additional information
     * regarding copyright ownership.  The ASF licenses this file
     * to you under the Apache License, Version 2.0 (the
     * "License"); you may not use this file except in compliance
     * with the License.  You may obtain a copy of the License at
     *
     *  http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing,
     * software distributed under the License is distributed on an
     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     * KIND, either express or implied.  See the License for the
     * specific language governing permissions and limitations
     * under the License.
     */
    -->
    <#assign itemCount = 0/>
    <#if parameters.list?exists>
         <@s.iterator value="parameters.list">
             <#assign itemCount = itemCount + 1/>
             <#if parameters.listKey?exists>
                 <#assign itemKey = stack.findValue(parameters.listKey)/>
             <#else>
                 <#assign itemKey = stack.findValue('top')/>
             </#if>
             <#if parameters.listValue?exists>
                 <#assign itemValue = stack.findString(parameters.listValue)/>
             <#else>
                 <#assign itemValue = stack.findString('top')/>
             </#if>
     <#assign itemKeyStr=itemKey.toString() />
     <#if (itemCount-1)%3 == 0>
     <tr>
     </#if>
     <td>

     <input type="checkbox" name="${parameters.name?html}" value="${itemKeyStr?html}" id="${parameters.name?html}-${itemCount}"<#rt/>
             <#if tag.contains(parameters.nameValue, itemKey)>
      checked="checked"<#rt/>
             </#if>
             <#if parameters.disabled?default(false)>
      disabled="disabled"<#rt/>
             </#if>
             <#if parameters.title?exists>
      title="${parameters.title?html}"<#rt/>
             </#if>
             <#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
             <#include "/${parameters.templateDir}/simple/common-attributes.ftl" />
     />
     <label for="${parameters.name?html}-${itemCount}" class="checkboxLabel">${itemValue?html}</label>
     </td>
     <#if itemCount%3 == 0>
     </tr>

     </#if>
         </@s.iterator>
    </#if>
    <input type="hidden" id="__multiselect_${parameters.id?html}" name="__multiselect_${parameters.name?html}" value=""<#rt/>
    <#if parameters.disabled?default(false)>
     disabled="disabled"<#rt/>
    </#if>
     />
    posted on 2011-06-14 12:18 secret_x15 閱讀(3155) 評論(0)  編輯  收藏 所屬分類: java
    主站蜘蛛池模板: 亚洲国产精品成人午夜在线观看| 久久久久久亚洲AV无码专区| 亚洲av中文无码字幕色不卡| 欧洲精品成人免费视频在线观看| 亚洲福利电影一区二区?| 国产亚洲精品免费| 亚洲熟妇AV乱码在线观看| 在线看片无码永久免费视频| 亚洲一线产区二线产区区| 成人免费无码大片A毛片抽搐色欲| 国产AV旡码专区亚洲AV苍井空| 国产精品成人免费视频网站京东| 91丁香亚洲综合社区| 免费看香港一级毛片| 黄页网址大全免费观看12网站| 无码国产精品一区二区免费3p | 你懂的免费在线观看网站| 亚洲自偷自偷图片| 亚洲乱色熟女一区二区三区蜜臀| 情侣视频精品免费的国产| 色婷婷亚洲十月十月色天| 成人浮力影院免费看| 亚洲av无码一区二区三区四区| 亚洲av高清在线观看一区二区 | 好吊色永久免费视频大全| 亚洲三区在线观看无套内射| 久久久久亚洲国产| 国产成人精品123区免费视频| 亚洲毛片基地日韩毛片基地| 午夜网站免费版在线观看| 大片免费观看92在线视频线视频 | 日本免费网址大全在线观看| 亚洲AV无码国产精品色午友在线 | 亚洲国产精品va在线播放| 青草青草视频2免费观看| 亚洲理论电影在线观看| 免费国产va视频永久在线观看| 国产卡二卡三卡四卡免费网址| 日韩在线视精品在亚洲| 四虎永久免费影院| 久久精品无码精品免费专区|