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

📄 ajaxautocompletetag.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 autocomplete AJAX tag.
 * 
 * @author Darren Spurgeon
 * @version $Revision$ $Date$ $Author$
 */
public class AjaxAutocompleteTag extends TagSupport {

  private String fieldId;

  private String popupId;

  private String targetId;

  private String baseUrl;

  private String paramName;

  private String className;

  private String postFunc;

  private String progressStyle;

  private String minimumCharacters;

  public String getClassName() {
    return paramName;
  }

  public void setClassName(String className) {
    this.className = className;
  }

  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 getPopupId() {
    return popupId;
  }

  public void setPopupId(String popupId) {
    this.popupId = popupId;
  }

  public String getPostFunc() {
    return postFunc;
  }

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

  public String getProgressStyle() {
    return progressStyle;
  }

  public void setProgressStyle(String progressStyle) {
    this.progressStyle = progressStyle;
  }

  public String getTargetId() {
    return targetId;
  }

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

  public String getBaseUrl() {
    return baseUrl;
  }

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

  public String getMinimumCharacters() {
    return minimumCharacters;
  }

  public void setMinimumCharacters(String waitTime) {
    this.minimumCharacters = waitTime;
  }

  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.popupId, this.className, this.fieldId,
        this.targetId, this.baseUrl, this.paramName, this.postFunc,
        this.progressStyle, this.minimumCharacters };
    String pattern = "<div id=\"{0}\" class=\"{1}\"></div>\n<script type=\"text/javascript\">\n  autocomplete(\"{2}\", \"{0}\", \"{3}\", \"{4}\", \"{5}\", {6}, \"{7}\", \"{8}\");\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.fieldId = null;
    this.popupId = null;
    this.targetId = null;
    this.baseUrl = null;
    this.paramName = null;
    this.className = null;
    this.postFunc = null;
    this.progressStyle = null;
    this.minimumCharacters = null;
    super.release();
  }

}

⌨️ 快捷键说明

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