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

📄 submittag.java

📁 struts+spring+hibernate自创框架
💻 JAVA
字号:
package com.pegasus.framework.component.taglib.html;


import org.apache.struts.taglib.TagUtils;
import org.apache.struts.taglib.html.Constants;
import org.apache.struts.util.MessageResources;

import javax.servlet.jsp.JspException;


public class SubmitTag extends ControlTag {

    // ----------------------------------------------------- Instance Variables


    /**
     * The message resources for this package.
     */
    protected static MessageResources messages =
            MessageResources.getMessageResources(Constants.Package + ".LocalStrings");


    /**
     * The name of the generated input field.
     */
    protected String property = null;


    /**
     * The body content of this tag (if any).
     */
    protected String text = null;


    /**
     * The value of the button label.
     */
    protected String value = null;

    // ------------------------------------------------------------- Properties


    /**
     * @return the property.
     */
    public String getProperty() {

        return (this.property);

    }


    /**
     * Set the property name.
     *
     * @param property The property name
     */
    public void setProperty(String property) {

        this.property = property;

    }


    /**
     * @return the label value.
     */
    public String getValue() {

        return (this.value);

    }


    /**
     * Set the label value.
     *
     * @param value The label value
     */
    public void setValue(String value) {

        this.value = value;

    }

    // --------------------------------------------------------- Public Methods


    /**
     * Process the start of this tag.
     * @return .
     * @throws JspException if a JSP exception has occurred
     */
    public int doStartTag() throws JspException {
        super.clear();
        // Do nothing until doEndTag() is called
        this.text = null;
        return (EVAL_BODY_TAG);

    }


    /**
     * Save the associated label from the body content.
     * @return .
     * @throws JspException if a JSP exception has occurred
     */
    public int doAfterBody() throws JspException {

        if (bodyContent != null) {
            String value = bodyContent.getString().trim();
            if (value.length() > 0) {
                text = value;
            }
        }
        return (SKIP_BODY);

    }


    /**
     * Process the end of this tag.
     * <p/>
     * Support for Indexed property since Struts 1.1
     *
     * @throws JspException if a JSP exception has occurred
     */
    public int doEndTag() throws JspException {

        // Acquire the label value we will be generating
        String label = value;
        if ((label == null) && (text != null)) {
            label = text;
        }
        if ((label == null) || (label.length() < 1)) {
            label = "Submit";
        }

        // Generate an HTML element
        StringBuffer buffer = new StringBuffer();
        buffer.append("<input type=\"submit\"");
        if (property != null) {
            buffer.append(" name=\"");
            buffer.append(property);
            // * @since Struts 1.1
            if (indexed) {
                prepareIndex(buffer, null);
            }
            buffer.append("\"");
        }

        if (accesskey != null) {
            buffer.append(" accesskey=\"");
            buffer.append(accesskey);
            buffer.append("\"");
        }
        if (tabindex != null) {
            buffer.append(" tabindex=\"");
            buffer.append(tabindex);
            buffer.append("\"");
        }
        buffer.append(" value=\"");
        buffer.append(label);
        buffer.append("\"");
        buffer.append(prepareEventHandlers());
        buffer.append(prepareStyles());
        buffer.append(getElementClose());
        boolean visible = condition();
        if (visible)
            TagUtils.getInstance().write(pageContext, buffer.toString());

        return (EVAL_PAGE);

    }


    /**
     * Release any acquired resources.
     */
    public void release() {

        super.release();
        property = null;
        text = null;
        value = null;

    }


}

⌨️ 快捷键说明

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