⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ajaxselecttag.java

📁 The AJAX JSP Tag Library is a set of JSP tags that simplify the use of Asynchronous JavaScript and X
💻 JAVA
字号:
/**
 * Copyright 2005 Darren L. Spurgeon
 * 
 * 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.ajaxtags.tags;

import java.io.IOException;
import java.text.MessageFormat;

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

import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;

/**
 * Tag handler for the select AJAX tag.
 * 
 * @author Darren Spurgeon
 * @version $Revision$ $Date$ $Author$
 */
public class AjaxSelectTag extends TagSupport {

  private String fieldId;

  private String targetId;

  private String baseUrl;

  private String paramName;

  private String postFunc;

  private String emptyFunc;

  private String errorFunc;

  public String getBaseUrl() {
    return baseUrl;
  }

  public void setBaseUrl(String baseUrl) {
    this.baseUrl = baseUrl;
  }

  public String getEmptyFunc() {
    return emptyFunc;
  }

  public void setEmptyFunc(String emptyFunc) {
    this.emptyFunc = emptyFunc;
  }

  public String getErrorFunc() {
    return errorFunc;
  }

  public void setErrorFunc(String errorFunc) {
    this.errorFunc = errorFunc;
  }

  public String getFieldId() {
    return fieldId;
  }

  public void setFieldId(String fieldId) {
    this.fieldId = fieldId;
  }

  public String getParamName() {
    return paramName;
  }

  public void setParamName(String paramName) {
    this.paramName = paramName;
  }

  public String getPostFunc() {
    return postFunc;
  }

  public void setPostFunc(String postFunc) {
    this.postFunc = postFunc;
  }

  public String getTargetId() {
    return targetId;
  }

  public void setTargetId(String targetId) {
    this.targetId = targetId;
  }

  public int doStartTag() throws JspException {
    this.baseUrl = (String) ExpressionEvaluatorManager.evaluate("baseUrl", this.baseUrl,
        String.class, this, super.pageContext);
    return SKIP_BODY;
  }

  public int doEndTag() throws JspException {
    Object[] arguments = { this.fieldId, this.targetId, this.baseUrl, this.paramName,
        this.postFunc, this.emptyFunc, this.errorFunc };
    String pattern = "<script type=\"text/javascript\">\n  populateSelect(\"{0}\", \"{1}\", \"{2}\", \"{3}\", {4}, {5}, {6});\n</script>\n\n";

    JspWriter writer = pageContext.getOut();
    try {
      writer.println(MessageFormat.format(pattern, arguments));
    } catch (IOException e) {
      throw new JspException(e.getMessage());
    }
    return EVAL_PAGE;
  }

  public void release() {
    this.baseUrl = null;
    this.fieldId = null;
    this.paramName = null;
    this.targetId = null;
    this.postFunc = null;
    this.emptyFunc = null;
    this.errorFunc = null;
    super.release();
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -