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

📄 viewtag.java

📁 一个专门用来快速开发网站的框架
💻 JAVA
字号:
package com.core.taglib;

import java.util.List;
import com.opensymphony.webwork.views.jsp.TagUtils;
import com.core.taglib.components.SelectOption;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;

/**
 <input name="jhgs" type="text" size="5" nullable="false" charset=Number
 datatype="Notfnumber" namevalue="计划工时">
 */

public class ViewTag extends javax.servlet.jsp.tagext.TagSupport {
    private static Log log = LogFactory.getLog(ViewTag.class);
    String name = "";
    String type = "";
    String size = "";
    boolean nullable = true;
    String charset = "";
    String datatype = "";
    String namevalue = "";

    public ViewTag() {
    }

    public int doStartTag() throws javax.servlet.jsp.JspException {
        return SKIP_BODY;
    }

    public int doEndTag() throws javax.servlet.jsp.JspException {
        try {
            String strHtml = getView();
            pageContext.getOut().print(strHtml);
        } catch (Exception e) {
            throw new javax.servlet.jsp.JspException(e);
        }

        return EVAL_BODY_INCLUDE;
    }

    /**
     * 下拉框和录入框的输出合二为一:
     * 1、如果缓存中没有就显示WW2中的数据。
     * 2、如果缓存中有就显示下拉框对应的数据。
     */
    public String getView() {
        String ret = "";
        Object stackObject = TagUtils.getStack(this.pageContext).findValue(name);
        String code = "";
        // 检查OgnlValueStack中是否有值
        if (null != stackObject) {
            code = stackObject.toString();
            log.info("在OgnlValueStack找到了" + name + "! 它的值是:" + code);
        }

        // 检查是否有缓存列表。
        List selectList = SelcetCache.getInstance().getSelect(name);
        if (null != selectList) {
            log.info("在SelcetCache找到了" + name + "! 它的值是:" + selectList);
            for (int i = 0; i < selectList.size(); i++) {
                SelectOption option = (SelectOption) selectList.get(i);
                if (option.getValue().equals(code)) {
                    ret = option.getTitle();
                    log.info("Selcet Value" + option.getValue() + "! Select Title:" + option.getTitle());
                }
            }
        } else {
            return ret = code;
        }
        return ret;
    }

    public String getCharset() {
        return charset;
    }

    public String getDatatype() {
        return datatype;
    }

    public String getName() {
        return name;
    }

    public String getNamevalue() {
        return namevalue;
    }

    public String getSize() {
        return size;
    }

    public String getType() {
        return type;
    }

    public boolean isNullable() {
        return nullable;
    }

    public void setCharset(String charset) {
        this.charset = charset;
    }

    public void setDatatype(String datatype) {
        this.datatype = datatype;
    }

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

    public void setNamevalue(String namevalue) {
        this.namevalue = namevalue;
    }

    public void setSize(String size) {
        this.size = size;
    }

    public void setType(String type) {
        this.type = type;
    }

    public void setNullable(boolean nullable) {
        this.nullable = nullable;
    }

}

⌨️ 快捷键说明

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