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

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

?? javascriptvalidatortag.java

?? struts的源代碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * $Id: JavascriptValidatorTag.java 383908 2006-03-07 15:33:42Z niallp $ 
 *
 * Copyright 2001-2005 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.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTagSupport;

import org.apache.commons.validator.Field;
import org.apache.commons.validator.Form;
import org.apache.commons.validator.ValidatorAction;
import org.apache.commons.validator.ValidatorResources;
import org.apache.commons.validator.Var;
import org.apache.commons.validator.util.ValidatorUtils;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.config.ModuleConfig;
import org.apache.struts.taglib.TagUtils;
import org.apache.struts.util.MessageResources;
import org.apache.struts.validator.Resources;
import org.apache.struts.validator.ValidatorPlugIn;

/**
 * Custom tag that generates JavaScript for client side validation based
 * on the validation rules loaded by the <code>ValidatorPlugIn</code>
 * defined in the struts-config.xml file.
 *
 * @version $Rev: 383908 $ $Date: 2006-03-07 15:33:42 +0000 (Tue, 07 Mar 2006) $
 * @since Struts 1.1
 */
public class JavascriptValidatorTag extends BodyTagSupport {

    /**
     * A Comparator to use when sorting ValidatorAction objects.
     */
    private static final Comparator actionComparator = new Comparator() {
        public int compare(Object o1, Object o2) {

            ValidatorAction va1 = (ValidatorAction) o1;
            ValidatorAction va2 = (ValidatorAction) o2;

            if ((va1.getDepends() == null || va1.getDepends().length() == 0)
                && (va2.getDepends() == null || va2.getDepends().length() == 0)) {
                return 0;

            } else if (
                (va1.getDepends() != null && va1.getDepends().length() > 0)
                    && (va2.getDepends() == null || va2.getDepends().length() == 0)) {
                return 1;

            } else if (
                (va1.getDepends() == null || va1.getDepends().length() == 0)
                    && (va2.getDepends() != null && va2.getDepends().length() > 0)) {
                return -1;

            } else {
                return va1.getDependencyList().size() - va2.getDependencyList().size();
            }
        }
    };

    /**
     * The start of the HTML comment hiding JavaScript from old browsers.
     * @since Struts 1.2
     */
    protected static final String HTML_BEGIN_COMMENT = "\n<!-- Begin \n";

    /**
     * The end of the HTML comment hiding JavaScript from old browsers.
     * @since Struts 1.2
     */
    protected static final String HTML_END_COMMENT = "//End --> \n";

    // ----------------------------------------------------------- Properties

    /**
     * The servlet context attribute key for our resources.
     */
    protected String bundle = Globals.MESSAGES_KEY;

    /**
     * The default locale on our server.
     * @deprecated This variable is no longer used.
     */
    protected static Locale defaultLocale = Locale.getDefault();

    /**
     * The name of the form that corresponds with the action name
     * in struts-config.xml. Specifying a form name places a
     * &lt;script&gt; &lt;/script&gt; around the javascript.
     */
    protected String formName = null;
    
    /**
     * formName is used for both Javascript and non-javascript validations.
     * For the javascript validations, there is the possibility that we will
     * be rewriting the formName (if it is a ValidatorActionForm instead of just
     * a ValidatorForm) so we need another variable to hold the formName just for
     * javascript usage.
     */
    protected String jsFormName = null;

    /**
     * The line ending string.
     */
    protected static String lineEnd = System.getProperty("line.separator");

    /**
     * The current page number of a multi-part form.
     * Only valid when the formName attribute is set.
     */
    protected int page = 0;

    /**
     * This will be used as is for the JavaScript validation method name if it has a value.  This is
     * the method name of the main JavaScript method that the form calls to perform validations.
     */
    protected String methodName = null;

    /**
     * Include language attribute in the &lt;script&gt; element.  This property is
     * ignored in XHTML mode.
     * @since Struts 1.2
     */
    protected boolean scriptLanguage = true;

    /**
     * The static JavaScript methods will only be printed if this is set to "true".
     */
    protected String staticJavascript = "true";

    /**
     * The dynamic JavaScript objects will only be generated if this is set to "true".
     */
    protected String dynamicJavascript = "true";

    /**
     * The src attribute for html script element (used to include an external script
     * resource). The src attribute is only recognized
     * when the formName attribute is specified.
     */
    protected String src = null;

    /**
     * The JavaScript methods will enclosed with html comments if this is set to "true".
     */
    protected String htmlComment = "true";

    /**
     * Hide JavaScript methods in a CDATA section for XHTML when "true".
     */
    protected String cdata = "true";

    /**
     * Gets the key (form name) that will be used
     * to retrieve a set of validation rules to be
     * performed on the bean passed in for validation.
     */
    public String getFormName() {
        return formName;
    }

    /**
     * Sets the key (form name) that will be used
     * to retrieve a set of validation rules to be
     * performed on the bean passed in for validation.
     * Specifying a form name places a
     * &lt;script&gt; &lt;/script&gt; tag around the javascript.
     */
    public void setFormName(String formName) {
        this.formName = formName;
    }

    /**
     * @return Returns the jsFormName.
     */
    public String getJsFormName() {
        return jsFormName;
    }
    /**
     * @param jsFormName The jsFormName to set.
     */
    public void setJsFormName(String jsFormName) {
        this.jsFormName = jsFormName;
    }
    /**
     * Gets the current page number of a multi-part form.
     * Only field validations with a matching page numer
     * will be generated that match the current page number.
     * Only valid when the formName attribute is set.
     */
    public int getPage() {
        return page;
    }

    /**
     * Sets the current page number of a multi-part form.
     * Only field validations with a matching page numer
     * will be generated that match the current page number.
     * Only valid when the formName attribute is set.
     */
    public void setPage(int page) {
        this.page = page;
    }

    /**
     * Gets the method name that will be used for the Javascript
     * validation method name if it has a value.  This overrides
     * the auto-generated method name based on the key (form name)
     * passed in.
     */
    public String getMethod() {
        return methodName;
    }

    /**
     * Sets the method name that will be used for the Javascript
     * validation method name if it has a value.  This overrides
     * the auto-generated method name based on the key (form name)
     * passed in.
     */
    public void setMethod(String methodName) {
        this.methodName = methodName;
    }

    /**
     * Gets whether or not to generate the static
     * JavaScript.  If this is set to 'true', which
     * is the default, the static JavaScript will be generated.
     */
    public String getStaticJavascript() {
        return staticJavascript;
    }

    /**
     * Sets whether or not to generate the static
     * JavaScript.  If this is set to 'true', which
     * is the default, the static JavaScript will be generated.
     */
    public void setStaticJavascript(String staticJavascript) {
        this.staticJavascript = staticJavascript;
    }

    /**
     * Gets whether or not to generate the dynamic
     * JavaScript.  If this is set to 'true', which
     * is the default, the dynamic JavaScript will be generated.
     */
    public String getDynamicJavascript() {
        return dynamicJavascript;
    }

    /**
     * Sets whether or not to generate the dynamic
     * JavaScript.  If this is set to 'true', which
     * is the default, the dynamic JavaScript will be generated.
     */
    public void setDynamicJavascript(String dynamicJavascript) {
        this.dynamicJavascript = dynamicJavascript;
    }

    /**
      * Gets whether or not to delimit the
      * JavaScript with html comments.  If this is set to 'true', which
      * is the default, the htmlComment will be surround the JavaScript.
      */
    public String getHtmlComment() {
        return htmlComment;
    }

    /**
     * Sets whether or not to delimit the
     * JavaScript with html comments.  If this is set to 'true', which
     * is the default, the htmlComment will be surround the JavaScript.
     */
    public void setHtmlComment(String htmlComment) {
        this.htmlComment = htmlComment;
    }

    /**
     * Gets the src attribute's value when defining
     * the html script element.
     */
    public String getSrc() {
        return src;
    }

    /**
     * Sets the src attribute's value when defining
     * the html script element. The src attribute is only recognized
     * when the formName attribute is specified.
     */
    public void setSrc(String src) {
        this.src = src;
    }

    /**
     * Sets the servlet context attribute key for our resources.
     */
    public String getBundle() {
        return bundle;
    }

    /**
     * Gets the servlet context attribute key for our resources.
     */
    public void setBundle(String bundle) {
        this.bundle = bundle;
    }

    /**
     * Render the JavaScript for to perform validations based on the form name.
     *
     * @exception JspException if a JSP exception has occurred
     */
    public int doStartTag() throws JspException {

        JspWriter writer = pageContext.getOut();
        try {
            writer.print(this.renderJavascript());

        } catch (IOException e) {
            throw new JspException(e.getMessage());
        }

        return EVAL_BODY_TAG;

    }

    /**
     * Returns fully rendered JavaScript.
     * @since Struts 1.2
     */
    protected String renderJavascript() throws JspException {
        StringBuffer results = new StringBuffer();

        ModuleConfig config = TagUtils.getInstance().getModuleConfig(pageContext);
        ValidatorResources resources =
            (ValidatorResources) pageContext.getAttribute(
                ValidatorPlugIn.VALIDATOR_KEY + config.getPrefix(),
                PageContext.APPLICATION_SCOPE);

        if (resources == null) {
            throw new JspException(
                "ValidatorResources not found in application scope under key \"" 
                + ValidatorPlugIn.VALIDATOR_KEY + config.getPrefix() + "\"");
        }        

        Locale locale = TagUtils.getInstance().getUserLocale(this.pageContext, null);

        Form form = resources.getForm(locale, formName);

        if ("true".equalsIgnoreCase(dynamicJavascript) && form == null)
        {
            throw new JspException("No form found under '"
                                   + formName
                                   + "' in locale '"
                                   + locale
                                   + "'");
        }

        if (form != null) {
            if ("true".equalsIgnoreCase(dynamicJavascript)) {
                results.append(
                        this.createDynamicJavascript(config, resources, locale, form));

            } else if ("true".equalsIgnoreCase(staticJavascript)) {
                results.append(this.renderStartElement());
                if ("true".equalsIgnoreCase(htmlComment)) {
                    results.append(HTML_BEGIN_COMMENT);
                }
            }
        }

        if ("true".equalsIgnoreCase(staticJavascript)) {
            results.append(getJavascriptStaticMethods(resources));
        }

        if (form != null
            && ("true".equalsIgnoreCase(dynamicJavascript)
                || "true".equalsIgnoreCase(staticJavascript))) {

            results.append(getJavascriptEnd());
        }

        return results.toString();
    }

    /**
     * Generates the dynamic JavaScript for the form.
     * @param config
     * @param resources
     * @param locale
     * @param form
     */
    private String createDynamicJavascript(
        ModuleConfig config,
        ValidatorResources resources,
        Locale locale,
        Form form) throws JspException {

        StringBuffer results = new StringBuffer();

        MessageResources messages = 
            TagUtils.getInstance().retrieveMessageResources(pageContext, bundle, true);
 
        HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
        ServletContext application = pageContext.getServletContext();

        List actions = this.createActionList(resources, form);

        final String methods = this.createMethods(actions, this.stopOnError(config));

        String formName = form.getName();
        jsFormName = formName;
                if(jsFormName.charAt(0) == '/') {
                    String mappingName = TagUtils.getInstance().getActionMappingName(jsFormName);
                    ActionMapping mapping = (ActionMapping) config.findActionConfig(mappingName);
                    if (mapping == null) {
                        JspException e = new JspException(messages.getMessage("formTag.mapping", mappingName));
                        pageContext.setAttribute(Globals.EXCEPTION_KEY, e, PageContext.REQUEST_SCOPE);
                        throw e;
                    }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美三级韩国三级日本三斤| 99免费精品视频| 欧美久久久一区| 丝袜美腿高跟呻吟高潮一区| 欧美日韩精品高清| 日韩激情av在线| 日韩欧美精品在线| 激情成人午夜视频| 久久久久一区二区三区四区| 成人午夜碰碰视频| 夜夜揉揉日日人人青青一国产精品| 欧美色综合影院| 免费在线视频一区| 国产日韩欧美a| 国产jizzjizz一区二区| 亚洲免费观看在线视频| 欧美日韩一区二区在线视频| 日韩高清一级片| 久久嫩草精品久久久精品一| 91麻豆.com| 91精品国产色综合久久不卡蜜臀 | 麻豆成人在线观看| 色狠狠桃花综合| 久久综合成人精品亚洲另类欧美| 国产成人免费视频网站高清观看视频| 中文字幕制服丝袜成人av| 色美美综合视频| 蜜芽一区二区三区| 国产精品毛片无遮挡高清| 欧美日韩一区三区四区| 国产在线精品一区二区| 亚洲黄色在线视频| 久久久国产综合精品女国产盗摄| 91麻豆福利精品推荐| 久88久久88久久久| 18成人在线观看| 亚洲精品一区二区三区精华液| 99精品欧美一区二区蜜桃免费| 日韩激情视频在线观看| 亚洲色图丝袜美腿| 日韩免费在线观看| 欧美性猛交一区二区三区精品| 国产在线视频一区二区| 亚洲电影激情视频网站| 国产精品久久久久久一区二区三区| 欧美精品99久久久**| 99久久久无码国产精品| 国产一区二区三区日韩| 视频一区二区三区中文字幕| 亚洲视频一二三| 国产欧美精品一区二区三区四区| 69精品人人人人| 在线欧美日韩精品| 不卡的看片网站| 蜜桃精品视频在线观看| av毛片久久久久**hd| 视频一区二区欧美| 一级做a爱片久久| 国产精品毛片a∨一区二区三区| 欧美一区二区三区影视| 91久久免费观看| aaa欧美日韩| 国产.精品.日韩.另类.中文.在线.播放| 午夜电影网一区| 亚洲精选视频在线| 亚洲另类在线一区| 1000部国产精品成人观看| 国产亚洲午夜高清国产拍精品 | 亚洲欧美日韩系列| 国产女人aaa级久久久级| 精品美女一区二区| 日韩欧美你懂的| 日韩区在线观看| 日韩午夜在线影院| 日韩亚洲欧美一区二区三区| 欧美久久久久免费| 日韩一区二区影院| 欧美一区二区三区喷汁尤物| 欧美一区二区三区系列电影| 欧美男女性生活在线直播观看| 欧美日韩1234| 欧美另类变人与禽xxxxx| 欧美久久久一区| 欧美一区二区精品在线| 欧美影院一区二区三区| 欧美日韩视频专区在线播放| 欧美一区二区性放荡片| 91亚洲精品久久久蜜桃| 久久综合色天天久久综合图片| 久久色在线视频| 91精品国产色综合久久ai换脸| 成人黄色一级视频| 99麻豆久久久国产精品免费| 欧美日韩一区二区不卡| 国产一区二区三区国产| 丁香啪啪综合成人亚洲小说| jvid福利写真一区二区三区| 91精彩视频在线观看| 欧美精选午夜久久久乱码6080| 欧美日韩成人综合| 精品日韩在线一区| 亚洲国产精品成人综合色在线婷婷 | 中文字幕免费一区| 一区二区三区日韩精品| 性欧美疯狂xxxxbbbb| 久久69国产一区二区蜜臀| 国产高清不卡二三区| 色综合婷婷久久| 日韩欧美国产一区二区三区| 国产肉丝袜一区二区| 一区二区成人在线| 紧缚捆绑精品一区二区| 色呦呦国产精品| 日韩一区二区在线观看视频| 中文字幕av资源一区| 三级影片在线观看欧美日韩一区二区| 国产尤物一区二区在线| 91浏览器打开| 精品国产成人在线影院| 国产精品二区一区二区aⅴ污介绍| 午夜精品福利一区二区三区av| 国产麻豆精品在线| 欧美在线观看一区二区| 久久精品欧美一区二区三区不卡 | 国产欧美一区二区精品忘忧草| 亚洲小少妇裸体bbw| 国产成人啪免费观看软件| 欧美日韩精品一区二区三区| 最近日韩中文字幕| 日韩国产高清影视| 99精品视频在线播放观看| 日韩免费看的电影| 一区二区久久久久| 国产成人精品免费网站| 欧美一级夜夜爽| 亚洲欧美日韩久久| 盗摄精品av一区二区三区| 欧美日韩成人综合在线一区二区 | 一区二区免费看| 国产91在线观看| 日韩一区二区在线播放| 亚洲综合男人的天堂| 成人妖精视频yjsp地址| 26uuu精品一区二区三区四区在线| 亚洲国产精品麻豆| fc2成人免费人成在线观看播放 | 综合久久给合久久狠狠狠97色| 国产伦精一区二区三区| 51精品秘密在线观看| 一区二区三区蜜桃| 91在线观看下载| 国产精品美女一区二区在线观看| 久草精品在线观看| 欧美大胆一级视频| 日本人妖一区二区| 在线观看91av| 午夜精品影院在线观看| 欧美日韩一区二区在线观看视频| 亚洲免费av在线| 一本久久精品一区二区| 亚洲精选在线视频| 在线欧美一区二区| 亚洲成va人在线观看| 欧美三级视频在线播放| 香蕉影视欧美成人| 9191国产精品| 日韩av一区二| 日韩精品专区在线影院观看| 免费高清在线视频一区·| 欧美一级艳片视频免费观看| 蜜臀a∨国产成人精品| 欧美成人综合网站| 久久超碰97人人做人人爱| 欧美大度的电影原声| 国产一区二区三区四区五区入口 | 九九视频精品免费| 久久欧美中文字幕| 国产成人福利片| 国产午夜亚洲精品理论片色戒| 成人a区在线观看| 亚洲靠逼com| 91麻豆精品国产无毒不卡在线观看| 日韩专区一卡二卡| 精品国内二区三区| 国产精品资源在线观看| 国产精品欧美综合在线| 91麻豆国产福利精品| 亚洲一区二区三区爽爽爽爽爽| 欧美精品久久久久久久多人混战| 视频在线观看国产精品| 久久久五月婷婷| 日本二三区不卡| 日韩av一区二区三区| 久久久久久久国产精品影院| 99精品视频在线观看免费| 日韩avvvv在线播放| 国产亚洲污的网站| 欧美三级电影在线看| 国产在线视频一区二区| 亚洲黄色免费电影|