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

📄 prevtag.java

📁 Java/J2EE框架Jdon-Framework系统的Sample
💻 JAVA
字号:
/**
 * Copyright 2005 Jdon.com
 * 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 com.jdon.strutsutil.taglib;

import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;


public class PrevTag extends TagSupport {

  private boolean disp = false;



  private String name = null;

  public String getName() {
    return name;
  }

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

  public int doStartTag() throws JspException {

    String dispStrs = (String) pageContext.getAttribute(MPageTag.DISP);
    if ( (dispStrs != null) && (!dispStrs.equals(""))) {
      if (dispStrs.equals("on"))
        disp = true;
      else if (dispStrs.equals("off"))
        disp = false;
    }

    String startStrs = (String) pageContext.getAttribute(MPageTag.START);
    int start = Integer.parseInt(startStrs);
    String url = (String) pageContext.getAttribute(MPageTag.URLNAME);
    String countStrs = (String) pageContext.getAttribute(MPageTag.COUNT);
    int count = Integer.parseInt(countStrs);

    StringBuffer buf = new StringBuffer(100);
    // Print out a left arrow if necessary
    if (start > 0) {

      buf.append("<a href=\"");
      buf.append(url);
      buf.append("&start=");
      buf.append( (start - count));
      buf.append("\" >");
      if (name != null)
         buf.append(name);
    } else
      buf.append("");

    output(buf.toString());

    return (EVAL_BODY_INCLUDE);

  }

  /**
   * Render the end of the hyperlink.
   *
   * @exception JspException if a JSP exception has occurred
   */
  public int doEndTag() throws JspException {
      output("</a>");

    return (EVAL_PAGE);

  }

  private void output(String s) throws JspException {
    HttpServletResponse response =
        (HttpServletResponse) pageContext.getResponse();
    JspWriter writer = pageContext.getOut();
    try {
      if (disp)
        writer.print(response.encodeURL(s));
    } catch (IOException e) {
      throw new JspException("NextTag error");
    }

  }

  public void release() {

   super.release();

   disp = false;

 }


}

⌨️ 快捷键说明

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