亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? optionstag.java

?? struts的源代碼
?? JAVA
字號:
/*
 * $Id: OptionsTag.java 190807 2005-06-15 21:01:56Z jholmes $ 
 *
 * Copyright 1999-2004 The Apache Software Foundation.
 * 
 * Licensed 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.
 */

package org.apache.struts.taglib.html;

import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.struts.util.IteratorAdapter;
import org.apache.struts.taglib.TagUtils;
import org.apache.struts.util.MessageResources;

/**
 * Tag for creating multiple <select> options from a collection.  The
 * associated values displayed to the user may optionally be specified by a
 * second collection, or will be the same as the values themselves.  Each
 * collection may be an array of objects, a Collection, an Enumeration,
 * an Iterator, or a Map.
 * <b>NOTE</b> - This tag requires a Java2 (JDK 1.2 or later) platform.
 *
 */

public class OptionsTag extends TagSupport {

    /**
     * The message resources for this package.
     */
    protected static MessageResources messages =
        MessageResources.getMessageResources(Constants.Package + ".LocalStrings");

    /**
     * The name of the collection containing beans that have properties to
     * provide both the values and the labels (identified by the
     * <code>property</code> and <code>labelProperty</code> attributes).
     */
    protected String collection = null;

    public String getCollection() {
        return (this.collection);
    }

    public void setCollection(String collection) {
        this.collection = collection;
    }

    /**
     * Should the label values be filtered for HTML sensitive characters?
     */
    protected boolean filter = true;

    public boolean getFilter() {
        return filter;
    }

    public void setFilter(boolean filter) {
        this.filter = filter;
    }

    /**
     * The name of the bean containing the labels collection.
     */
    protected String labelName = null;

    public String getLabelName() {
        return labelName;
    }

    public void setLabelName(String labelName) {
        this.labelName = labelName;
    }

    /**
     * The bean property containing the labels collection.
     */
    protected String labelProperty = null;

    public String getLabelProperty() {
        return labelProperty;
    }

    public void setLabelProperty(String labelProperty) {
        this.labelProperty = labelProperty;
    }

    /**
     * The name of the bean containing the values collection.
     */
    protected String name = null;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * The name of the property to use to build the values collection.
     */
    protected String property = null;

    public String getProperty() {
        return property;
    }

    public void setProperty(String property) {
        this.property = property;
    }

    /**
     * The style associated with this tag.
     */
    private String style = null;

    public String getStyle() {
        return style;
    }

    public void setStyle(String style) {
        this.style = style;
    }

    /**
     * The named style class associated with this tag.
     */
    private String styleClass = null;

    public String getStyleClass() {
        return styleClass;
    }

    public void setStyleClass(String styleClass) {
        this.styleClass = styleClass;
    }

    /**
     * Process the start of this tag.
     *
     * @exception JspException if a JSP exception has occurred
     */

    public int doStartTag() throws JspException {
        return SKIP_BODY;
    }

    /**
     * Process the end of this tag.
     *
     * @exception JspException if a JSP exception has occurred
     */
    public int doEndTag() throws JspException {

        // Acquire the select tag we are associated with
        SelectTag selectTag = (SelectTag) pageContext.getAttribute(Constants.SELECT_KEY);
        if (selectTag == null) {
            throw new JspException(messages.getMessage("optionsTag.select"));
        }
        StringBuffer sb = new StringBuffer();

        // If a collection was specified, use that mode to render options
        if (collection != null) {
            Iterator collIterator = getIterator(collection, null);
            while (collIterator.hasNext()) {

                Object bean = collIterator.next();
                Object value = null;
                Object label = null;

                try {
                    value = PropertyUtils.getProperty(bean, property);
                    if (value == null) {
                        value = "";
                    }
                } catch (IllegalAccessException e) {
                    throw new JspException(
                        messages.getMessage("getter.access", property, collection));
                } catch (InvocationTargetException e) {
                    Throwable t = e.getTargetException();
                    throw new JspException(
                        messages.getMessage("getter.result", property, t.toString()));
                } catch (NoSuchMethodException e) {
                    throw new JspException(
                        messages.getMessage("getter.method", property, collection));
                }

                try {
                    if (labelProperty != null) {
                        label = PropertyUtils.getProperty(bean, labelProperty);
                    } else {
                        label = value;
                    }

                    if (label == null) {
                        label = "";
                    }
                } catch (IllegalAccessException e) {
                    throw new JspException(
                        messages.getMessage("getter.access", labelProperty, collection));
                } catch (InvocationTargetException e) {
                    Throwable t = e.getTargetException();
                    throw new JspException(
                        messages.getMessage("getter.result", labelProperty, t.toString()));
                } catch (NoSuchMethodException e) {
                    throw new JspException(
                        messages.getMessage("getter.method", labelProperty, collection));
                }

                String stringValue = value.toString();
                addOption(sb, stringValue, label.toString(), selectTag.isMatched(stringValue));

            }

        }

        // Otherwise, use the separate iterators mode to render options
        else {

            // Construct iterators for the values and labels collections
            Iterator valuesIterator = getIterator(name, property);
            Iterator labelsIterator = null;
            if ((labelName != null) || (labelProperty != null)) {
                labelsIterator = getIterator(labelName, labelProperty);
            }

            // Render the options tags for each element of the values coll.
            while (valuesIterator.hasNext()) {
                Object valueObject = valuesIterator.next();
                if (valueObject == null) {
                    valueObject = "";
                }
                String value = valueObject.toString();
                String label = value;
                if ((labelsIterator != null) && labelsIterator.hasNext()) {
                    Object labelObject = labelsIterator.next();
                    if (labelObject == null) {
                        labelObject = "";
                    }
                    label = labelObject.toString();
                }
                addOption(sb, value, label, selectTag.isMatched(value));
            }
        }

        TagUtils.getInstance().write(pageContext, sb.toString());

        return EVAL_PAGE;

    }

    /**
     * Release any acquired resources.
     */
    public void release() {

        super.release();
        collection = null;
        filter = true;
        labelName = null;
        labelProperty = null;
        name = null;
        property = null;
        style = null;
        styleClass = null;
    }

    // ------------------------------------------------------ Protected Methods

    /**
     * Add an option element to the specified StringBuffer based on the
     * specified parameters.
     *<p>
     * Note that this tag specifically does not support the
     * <code>styleId</code> tag attribute, which causes the HTML
     * <code>id</code> attribute to be emitted.  This is because the HTML
     * specification states that all "id" attributes in a document have to be
     * unique.  This tag will likely generate more than one <code>option</code>
     * element element, but it cannot use the same <code>id</code> value.  It's
     * conceivable some sort of mechanism to supply an array of <code>id</code>
     * values could be devised, but that doesn't seem to be worth the trouble.
     *
     * @param sb StringBuffer accumulating our results
     * @param value Value to be returned to the server for this option
     * @param label Value to be shown to the user for this option
     * @param matched Should this value be marked as selected?
     */
    protected void addOption(StringBuffer sb, String value, String label, boolean matched) {

        sb.append("<option value=\"");
        if (filter) {
            sb.append(TagUtils.getInstance().filter(value));
        } else {
            sb.append(value);
        }
        sb.append("\"");
        if (matched) {
            sb.append(" selected=\"selected\"");
        }
        if (style != null) {
            sb.append(" style=\"");
            sb.append(style);
            sb.append("\"");
        }
        if (styleClass != null) {
            sb.append(" class=\"");
            sb.append(styleClass);
            sb.append("\"");
        }
        
        sb.append(">");
        
        if (filter) {
            sb.append(TagUtils.getInstance().filter(label));
        } else {
            sb.append(label);
        }
        
        sb.append("</option>\r\n");

    }

    /**
     * Return an iterator for the option labels or values, based on our
     * configured properties.
     *
     * @param name Name of the bean attribute (if any)
     * @param property Name of the bean property (if any)
     *
     * @exception JspException if an error occurs
     */
    protected Iterator getIterator(String name, String property) throws JspException {

        // Identify the bean containing our collection
        String beanName = name;
        if (beanName == null) {
            beanName = Constants.BEAN_KEY;
        }

        Object bean = TagUtils.getInstance().lookup(pageContext, beanName, null);
        if (bean == null) {
            throw new JspException(messages.getMessage("getter.bean", beanName));
        }

        // Identify the collection itself
        Object collection = bean;
        if (property != null) {
            try {
                collection = PropertyUtils.getProperty(bean, property);
                if (collection == null) {
                    throw new JspException(messages.getMessage("getter.property", property));
                }
            } catch (IllegalAccessException e) {
                throw new JspException(messages.getMessage("getter.access", property, name));
            } catch (InvocationTargetException e) {
                Throwable t = e.getTargetException();
                throw new JspException(
                    messages.getMessage("getter.result", property, t.toString()));
            } catch (NoSuchMethodException e) {
                throw new JspException(messages.getMessage("getter.method", property, name));
            }
        }

        // Construct and return an appropriate iterator
        if (collection.getClass().isArray()) {
            collection = Arrays.asList((Object[]) collection);
        }

        if (collection instanceof Collection) {
            return (((Collection) collection).iterator());

        } else if (collection instanceof Iterator) {
            return ((Iterator) collection);

        } else if (collection instanceof Map) {
            return (((Map) collection).entrySet().iterator());

        } else if (collection instanceof Enumeration) {
            return new IteratorAdapter((Enumeration) collection);

        } else {
            throw new JspException(
                messages.getMessage("optionsTag.iterator", collection.toString()));
        }
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩国产天堂| 国产精品美女久久久久久久久| 欧美电影免费观看高清完整版在 | 六月丁香综合在线视频| 国产精品一区二区久久不卡 | 国产精品系列在线观看| 色婷婷狠狠综合| 国产午夜精品福利| 日韩av中文字幕一区二区三区| 成人教育av在线| 91精品国产品国语在线不卡| 最新日韩av在线| 国产成人在线色| 久久午夜老司机| 婷婷亚洲久悠悠色悠在线播放| av一区二区三区| 久久久久国产精品麻豆 | 亚洲欧洲美洲综合色网| 老司机精品视频在线| 精品视频在线免费看| 国产精品福利影院| 国产成人免费高清| 欧美精品一区二区久久久| 亚洲一区二区三区四区在线观看| 成人美女视频在线看| 精品久久99ma| 蜜臀av国产精品久久久久| 欧美日韩一区小说| 一区二区三区加勒比av| 91福利在线免费观看| 国产精品对白交换视频| 丰满亚洲少妇av| 久久精品一区八戒影视| 国产一区二区日韩精品| 精品欧美一区二区久久| 奇米精品一区二区三区四区 | 88在线观看91蜜桃国自产| 一区二区三区精品在线| 91成人在线免费观看| 一区二区三区在线看| 在线观看日产精品| 亚洲精品第1页| 欧美日韩视频第一区| 午夜日韩在线观看| 91精品国产福利| 麻豆精品在线观看| 精品国产成人系列| 国产不卡视频一区| 最新高清无码专区| 欧美色欧美亚洲另类二区| 午夜电影网一区| 69久久99精品久久久久婷婷| 视频一区二区国产| 精品奇米国产一区二区三区| 国产一区二区三区在线观看免费 | 欧美亚洲国产一区在线观看网站 | 日韩av电影免费观看高清完整版 | 亚洲综合自拍偷拍| 欧美精品欧美精品系列| 麻豆91免费看| 国产欧美精品在线观看| 欧美午夜一区二区三区| 奇米一区二区三区av| 精品国产青草久久久久福利| 成人午夜又粗又硬又大| 一区二区在线观看免费视频播放 | 日韩三级.com| 国产福利一区在线| 一区二区三区四区不卡视频| 8v天堂国产在线一区二区| 国产经典欧美精品| 亚洲午夜久久久久久久久电影院| 91精品国产综合久久香蕉麻豆| 久久精品99国产国产精| 国产精品久久三| 欧美精选在线播放| 岛国精品一区二区| 亚洲成a人片在线观看中文| 久久夜色精品国产欧美乱极品| 不卡的av电影| 麻豆精品久久精品色综合| 亚洲欧美在线高清| 欧美一级欧美一级在线播放| 99视频在线精品| 美国十次综合导航| 亚洲精品久久嫩草网站秘色| 欧美一区二区福利在线| 97aⅴ精品视频一二三区| 久久国产精品99精品国产 | 99久久伊人精品| 免费精品视频最新在线| 一区二区欧美精品| 中文字幕精品一区二区三区精品| 91精品国产欧美日韩| 日本福利一区二区| 成人久久视频在线观看| 久久99这里只有精品| 亚洲一区在线视频| 国产精品久线在线观看| 国产三级精品三级在线专区| 欧美一区二区精美| 51精品视频一区二区三区| 91毛片在线观看| 成人黄色av电影| 国产成人欧美日韩在线电影| 麻豆精品视频在线观看免费| 视频在线在亚洲| 亚洲男人的天堂av| 国产欧美精品一区| 精品国产sm最大网站免费看| 欧美性生交片4| 国产91精品一区二区| 亚洲一二三四久久| 国产精品美女久久久久av爽李琼| 欧美一区二区在线观看| 在线观看国产日韩| 成人免费黄色大片| 日韩不卡在线观看日韩不卡视频| 亚洲高清久久久| 亚洲精品欧美专区| 中文字幕精品一区二区三区精品| 日韩情涩欧美日韩视频| 欧美丰满美乳xxx高潮www| 91小视频免费观看| 丁香婷婷综合五月| 国产精一区二区三区| 久久97超碰国产精品超碰| 日韩精品久久理论片| 亚洲乱码国产乱码精品精98午夜 | 久久天堂av综合合色蜜桃网| 欧美性生活一区| 欧美色图片你懂的| 欧美在线一二三四区| 日本韩国一区二区三区视频| 91免费看`日韩一区二区| 国产激情91久久精品导航| 美女精品一区二区| 国产成a人亚洲| 国产精品中文字幕日韩精品| 久草中文综合在线| 极品少妇xxxx偷拍精品少妇| 久久se这里有精品| 久久er精品视频| 国产电影精品久久禁18| 国产精品一区二区三区99| 国产91清纯白嫩初高中在线观看| 国产成人精品综合在线观看| 美女视频网站黄色亚洲| 国产成a人亚洲| 亚洲国产高清不卡| 精品欧美一区二区三区精品久久| 波多野结衣亚洲| 国产日韩欧美不卡在线| 高清在线成人网| 亚洲精品视频观看| 久久久久久日产精品| 久久综合狠狠综合久久综合88| 精品国产免费久久| 国产精品丝袜久久久久久app| 9191成人精品久久| 中文字幕欧美日本乱码一线二线| 中文字幕在线不卡| 亚洲综合激情小说| 六月丁香婷婷久久| 成人av网址在线| 日韩一区二区三区视频在线观看| 欧美一级一区二区| 欧美国产一区二区在线观看| 亚洲婷婷综合色高清在线| 亚洲va国产va欧美va观看| 亚洲日本在线a| 国精品**一区二区三区在线蜜桃| 不卡的电视剧免费网站有什么| 欧美日韩在线不卡| 久久久不卡网国产精品二区| 一区二区三区视频在线观看| 国产一区二区三区av电影 | 久久精品亚洲精品国产欧美 | 中文字幕日本不卡| 亚洲成av人片观看| 国产激情精品久久久第一区二区| 色婷婷亚洲综合| 日韩精品一区二区三区在线播放| 最新久久zyz资源站| 美女视频网站黄色亚洲| 91视频在线看| 日韩精品在线一区二区| 欧美极品另类videosde| 久久国产精品72免费观看| 在线一区二区三区做爰视频网站| 欧美xxx久久| 午夜精品久久久久久久蜜桃app| 日av在线不卡| 欧美一区二区三区视频免费播放| 国产精品久久99| 国内精品免费在线观看| 欧美精品免费视频| 精品福利在线导航| 精品一区二区影视| 欧美精品粉嫩高潮一区二区|