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

📄 ajaxtoggletag.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 toggle (on/off, true/false) AJAX tag.
 * 
 * @author Darren Spurgeon
 * @version $Revision$ $Date$ $Author$
 */
public class AjaxToggleTag extends TagSupport {

  private String imageId;

  private String targetId;

  private String stateId;

  private String baseUrl;

  private String paramName;

  private String imageOn;

  private String imageOff;

  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 getImageId() {
    return imageId;
  }

  public void setImageId(String imageId) {
    this.imageId = imageId;
  }

  public String getImageOff() {
    return imageOff;
  }

  public void setImageOff(String imageOff) {
    this.imageOff = imageOff;
  }

  public String getImageOn() {
    return imageOn;
  }

  public void setImageOn(String imageOn) {
    this.imageOn = imageOn;
  }

  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 getStateId() {
    return stateId;
  }

  public void setStateId(String stateId) {
    this.stateId = stateId;
  }

  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);
    this.imageOn = (String) ExpressionEvaluatorManager.evaluate("imageOn", this.imageOn,
        String.class, this, super.pageContext);
    this.imageOff = (String) ExpressionEvaluatorManager.evaluate("imageOff", this.imageOff,
        String.class, this, super.pageContext);
    return SKIP_BODY;
  }

  public int doEndTag() throws JspException {
    Object[] arguments = { this.imageId, this.targetId, this.stateId, this.baseUrl, this.paramName,
        this.imageOn, this.imageOff, this.postFunc, this.emptyFunc, this.errorFunc };
    String pattern = "<script type=\"text/javascript\">\n  toggle(\"{0}\", \"{1}\", \"{2}\", \"{3}\", \"{4}\", \"{5}\", \"{6}\", {7}, {8}, {9});\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.imageId = null;
    this.targetId = null;
    this.stateId = null;
    this.baseUrl = null;
    this.imageOn = null;
    this.imageOff = null;
    this.postFunc = null;
    this.emptyFunc = null;
    this.errorFunc = null;
    super.release();
  }

}

⌨️ 快捷键说明

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