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

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

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

    struts2的s:checkboxlist標(biāo)簽學(xué)習(xí)

    struts2里增加了一個(gè)新的UT標(biāo)簽s:checkboxlist,下面介紹下使用方法。
    s:checkboxlist用于畫面上顯示一組復(fù)選框,缺省是橫排輸出,后面將介紹如何修改ftl文件使得它能按任意方式輸出。
    標(biāo)簽格式:
        <s:checkboxlist name="" list="" listKey="" listValue="" value="" />
        name-定義標(biāo)簽名,用于接收畫面上選中的復(fù)選框,故應(yīng)與Action里定義的屬性一致,且多為數(shù)組;
        list-定義集合變量,用于輸出復(fù)選框到畫面上,一般在Action里定義一個(gè)List或Map屬性;
        listKey-如果在Action里定義的是一個(gè)List,則往往會(huì)在List里定義一個(gè)Bean,它只有兩個(gè)屬性,其中一個(gè)(比如id)就在這里設(shè)置;
                    如果在Action里定義的是一個(gè)Map,則Map的key就在這里設(shè)置;
        listValue-如果在Action里定義的是一個(gè)List,則往往會(huì)在List里定義一個(gè)Bean,它只有兩個(gè)屬性,另外一個(gè)(比如name)就在這里設(shè)置;
                      如果在Action里定義的是一個(gè)Map,則Map的value就在這里設(shè)置;
        value-用于回顯畫面上被選中的復(fù)選框,假如畫面有輸入檢查,如果有錯(cuò)則返回原畫面并顯示出錯(cuò)信息,這時(shí)候就需要使用它。
                 一般把它設(shè)成和name一致就可以了。
    注意點(diǎn):
        為了能正確顯示已被選中的復(fù)選框,一定要使得name的數(shù)組類型與listKey的類型一致。
        比如,name設(shè)成String[] users,則listKey就要設(shè)成String id;如果name設(shè)成Integer[] users,則listKey就要設(shè)成Integer id;
    修改ftl文件改變輸出方式:
        1.搜索struts2-core-xxx.jar,找到checkboxlist.ftl文件,拷貝出來(lái);
        2.在自己的工程的src下新建template.simple包,放置上述文件;
        3.用文本編輯器打開該文件,修改成自己希望輸出的格式,保存,OK;
    例子:
        希望畫面上每3個(gè)復(fù)選框輸出為一行。
    <#--
    /*
     * $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 2009-12-27 00:16 koradji 閱讀(12041) 評(píng)論(0)  編輯  收藏 所屬分類: java

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    導(dǎo)航

    統(tǒng)計(jì)

    常用鏈接

    留言簿(2)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    收藏夾

    db2

    dos

    Groovy

    Hibernate

    java

    WAS

    web application

    搜索

    最新評(píng)論

    閱讀排行榜

    評(píng)論排行榜

    主站蜘蛛池模板: 久久成人国产精品免费软件| 99久久精品日本一区二区免费| 亚洲日韩图片专区第1页| 国产精品成人观看视频免费| 亚洲国产精华液2020| 国产AV无码专区亚洲AWWW| 精品无码国产污污污免费网站| 亚洲最大的成人网站| 亚洲人成精品久久久久| 日韩免费a级毛片无码a∨| 国产日韩AV免费无码一区二区三区 | 精品国产综合成人亚洲区| 亚洲精品免费网站| 精品久久久久久无码免费| 一本色道久久88—综合亚洲精品| 亚洲综合日韩久久成人AV| 久久精品网站免费观看| 中文字幕免费在线看| 亚洲AV无码一区二区一二区| 亚洲AV一宅男色影视| 五月婷婷亚洲综合| 国内免费高清在线观看| 暖暖免费在线中文日本| 国产精品亚洲二区在线| 亚洲一区二区三区不卡在线播放| 国产亚洲大尺度无码无码专线| 免费无码又爽又高潮视频| 在线观看免费视频资源| 97在线视频免费公开视频| 国产成人亚洲综合无| 亚洲综合欧美色五月俺也去| 亚洲图片一区二区| 亚洲熟妇av一区二区三区| 免费少妇a级毛片| 成人免费无遮挡无码黄漫视频| 少妇太爽了在线观看免费视频 | 我想看一级毛片免费的| 99re视频精品全部免费| 中文字幕免费播放| 久久精品免费大片国产大片 | 国产精品九九久久免费视频|