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

📄 input.java

📁 这是一个mvc模式
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package jsp.tags.dapact.tags.html;

import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import jsp.tags.dapact.BaseDataTagSupport;
import jsp.tags.dapact.util.TagUtil;
/**
 * Title:        Data Aware Processing And Control Tags
 * Description:  Tag library for the processing and controlling the input and output of data.
 * Copyright:    LGPL (http://www.gnu.org/copyleft/lesser.html)
 * Compile Date: @compile_date@
 * @author Allen M Servedio
 * @amp_sign@version @VERSION@
 */

/**
 * Implements a data aware HTML <input> tag.
 */
public class Input extends BaseDataTagSupport
{
  /**
   * Default constructor.
   */
  public Input()
  {
  }

  /**
   * Called when the starting tag is found - writes the start tag and its attributes.
   *
   * @return EVAL_BODY_INCLUDE so that it processes what ever is in the body.
   */
  public int doStartTag() throws JspException
  {
    // The super class will lookup and set the new value in the new value property.
    super.doStartTag();

    // If this is a checkbox or radio button, set the checked state and set the value
    // back to what the user specified.
    if (isCheckboxOrRadioButton())
    {
      setCheckedState();
    }
    else
    {
      String valAsStr = TagUtil.getStringFromObj(getNewValue());
      if (valAsStr != null)
      {
        setValue(valAsStr);
      }
    }

    try
    {
      JspWriter out = pageContext.getOut();
      out.write("<input");
      out.write(TagUtil.getAllAttrAsStr(getValues(), this));
      out.write(">");
    }
    catch (IOException e)
    {
      throw new JspException("JspWriter not there: " + e);
    }
    return EVAL_BODY_INCLUDE;
  }

  /**
   * Called at the end of the tag. Will output the end body tag text and return that
   * it wants to have the rest of the page processed.
   *
   * @exception JspException general JSP exception.
   *
   * @return EVAL_PAGE so that it continues to process the rest of the page.
   */
  public int doEndTag() throws JspException
  {
    super.doEndTag();
    try
    {
      JspWriter out = pageContext.getOut();
      out.write("</input>");
    }
    catch (IOException e)
    {
      throw new JspException("JspWriter not there: " + e);
    }
    return EVAL_PAGE;
  }

  /**
   * Returns if the tag is a checkbox or radio button.
   *
   * @return <code>true</code> if it is a radio button or check box, else <code>false</code>
   */
  public boolean isCheckboxOrRadioButton()
  {
    String localType = getType();
    if ((localType != null) && ((localType.trim().equalsIgnoreCase("checkbox")) || (localType.trim().equalsIgnoreCase("radio"))))
    {
      return true;
    }
    return false;
  }

  /**
   * This assumes that it has already been checked to see that it is a check box or
   * radio button... So it sets the checked property to an empty string if its value
   * matches the value passed in.
   *
   * @param value the original value to of the tag's value property against.
   *
   * @return <code>true</code> if it matches.
   */
  protected boolean setCheckedState()
  {
    // Get the value by lookup.
    String tagVal = TagUtil.getStringFromObj(getNewValue());
    // If there is a value and it is equal to the control's value, set the checked
    //  attribute.
    if ((tagVal != null) && (tagVal.equalsIgnoreCase(getValue())))
    {
      setChecked("");
      return true;
    }
    setChecked(null);
    return false;
  }

  /*=============================================================================*/
  /*                           PROPERTIES/ATTRIBUTES                             */
  /*=============================================================================*/
  /**
   * Constant that specifies the value of the name of the accesskey property.
   */
  public static final String ACCESSKEY_PROP = "accesskey";
  /**
   * Get the value of the accesskey property.
   *
   * @return the value of the accesskey property.
   */
  public String getAccesskey()
  {
    return (String)getValue(ACCESSKEY_PROP);
  }
  /**
   * Set the value of the accesskey property.
   *
   * @param value the value of the accesskey property.
   */
  public void setAccesskey(String value)
  {
    setValue(ACCESSKEY_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the align property.
   */
  public static final String ALIGN_PROP = "align";
  /**
   * Get the value of the align property.
   *
   * @return the value of the align property.
   */
  public String getAlign()
  {
    return (String)getValue(ALIGN_PROP);
  }
  /**
   * Set the value of the align property.
   *
   * @param value the value of the align property.
   */
  public void setAlign(String value)
  {
    setValue(ALIGN_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the alt property.
   */
  public static final String ALT_PROP = "alt";
  /**
   * Get the value of the alt property.
   *
   * @return the value of the alt property.
   */
  public String getAlt()
  {
    return (String)getValue(ALT_PROP);
  }
  /**
   * Set the value of the alt property.
   *
   * @param value the value of the alt property.
   */
  public void setAlt(String value)
  {
    setValue(ALT_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the checked property.
   */
  public static final String CHECKED_PROP = "checked";
  /**
   * Get the value of the checked property.
   *
   * @return the value of the checked property.
   */
  public String getChecked()
  {
    return (String)getValue(CHECKED_PROP);
  }
  /**
   * Set the value of the checked property.
   *
   * @param value the value of the checked property.
   */
  public void setChecked(String value)
  {
    setValue(CHECKED_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the _class property.
   */
  public static final String _CLASS_PROP = "class";
  /**
   * Get the value of the _class property (will be written as 'class' when the attributes are written).
   *
   * @return the value of the _class property.
   */
  public String get_class()
  {
    return (String)getValue(_CLASS_PROP);
  }
  /**
   * Set the value of the _class property  (will be written as 'class' when the attributes are written).
   *
   * @param value the value of the _class property.
   */
  public void set_class(String value)
  {
    setValue(_CLASS_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the default property.
   */
  public static final String DEFAULT_PROP = "default";
  /**
   * Get the value of the default property.
   *
   * @return the value of the default property.
   */
  public String getDefault()
  {
    return (String)getValue(DEFAULT_PROP);
  }
  /**
   * Set the value of the default property.
   *
   * @param value the value of the default property.
   */
  public void setDefault(String value)
  {
    setValue(DEFAULT_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the dir property.
   */
  public static final String DIR_PROP = "dir";
  /**
   * Get the value of the dir property.
   *
   * @return the value of the dir property.
   */
  public String getDir()
  {
    return (String)getValue(DIR_PROP);
  }
  /**
   * Set the value of the dir property.
   *
   * @param value the value of the dir property.
   */
  public void setDir(String value)
  {
    setValue(DIR_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the disabled property.
   */
  public static final String DISABLED_PROP = "disabled";
  /**
   * Get the value of the disabled property.
   *
   * @return the value of the disabled property.
   */
  public String getDisabled()
  {
    return (String)getValue(DISABLED_PROP);
  }
  /**
   * Set the value of the disabled property.
   *
   * @param value the value of the disabled property.
   */
  public void setDisabled(String value)
  {
    setValue(DISABLED_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the height property.
   */
  public static final String HEIGHT_PROP = "height";
  /**
   * Get the value of the height property.
   *
   * @return the value of the height property.
   */
  public String getHeight()
  {
    return (String)getValue(HEIGHT_PROP);
  }
  /**
   * Set the value of the height property.
   *
   * @param value the value of the height property.
   */
  public void setHeight(String value)
  {
    setValue(HEIGHT_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the hspace property.
   */
  public static final String HSPACE_PROP = "hspace";
  /**
   * Get the value of the hspace property.
   *
   * @return the value of the hspace property.
   */
  public String getHspace()
  {
    return (String)getValue(HSPACE_PROP);
  }
  /**
   * Set the value of the hspace property.
   *
   * @param value the value of the hspace property.
   */
  public void setHspace(String value)
  {
    setValue(HSPACE_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the id property.
   */
  public static final String ID_PROP = "id";
  /**
   * Get the value of the id property.
   *
   * @return the value of the id property.
   */
  public String getId()
  {
    return (String)getValue(ID_PROP);
  }
  /**
   * Set the value of the id property.
   *
   * @param value the value of the id property.
   */
  public void setId(String value)
  {
    super.setId(value);
    setValue(ID_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the lang property.
   */
  public static final String LANG_PROP = "lang";
  /**
   * Get the value of the lang property.
   *
   * @return the value of the lang property.
   */
  public String getLang()
  {
    return (String)getValue(LANG_PROP);
  }
  /**
   * Set the value of the lang property.
   *
   * @param value the value of the lang property.
   */
  public void setLang(String value)
  {
    setValue(LANG_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the listcontents property.
   */
  public static final String LISTCONTENTS_PROP = "listcontents";
  /**
   * Get the value of the listcontents property.
   *
   * @return the value of the listcontents property.
   */
  public String getListcontents()
  {
    return (String)getValue(LISTCONTENTS_PROP);
  }
  /**
   * Set the value of the listcontents property.
   *
   * @param value the value of the listcontents property.
   */
  public void setListcontents(String value)
  {
    setValue(LISTCONTENTS_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the maxlength property.
   */
  public static final String MAXLENGTH_PROP = "maxlength";
  /**
   * Get the value of the maxlength property.
   *
   * @return the value of the maxlength property.
   */
  public String getMaxlength()
  {
    return (String)getValue(MAXLENGTH_PROP);
  }
  /**
   * Set the value of the maxlength property.
   *
   * @param value the value of the maxlength property.
   */
  public void setMaxlength(String value)
  {
    setValue(MAXLENGTH_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the onblur property.
   */
  public static final String ONBLUR_PROP = "onblur";
  /**
   * Get the value of the onblur property.
   *
   * @return the value of the onblur property.
   */
  public String getOnblur()
  {
    return (String)getValue(ONBLUR_PROP);
  }
  /**
   * Set the value of the onblur property.
   *
   * @param value the value of the onblur property.
   */
  public void setOnblur(String value)
  {
    setValue(ONBLUR_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the onchange property.
   */
  public static final String ONCHANGE_PROP = "onchange";
  /**
   * Get the value of the onchange property.
   *
   * @return the value of the onchange property.
   */
  public String getOnchange()
  {
    return (String)getValue(ONCHANGE_PROP);
  }
  /**
   * Set the value of the onchange property.
   *
   * @param value the value of the onchange property.
   */
  public void setOnchange(String value)
  {
    setValue(ONCHANGE_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the onclick property.
   */
  public static final String ONCLICK_PROP = "onclick";
  /**
   * Get the value of the onclick property.
   *
   * @return the value of the onclick property.
   */
  public String getOnclick()
  {
    return (String)getValue(ONCLICK_PROP);
  }
  /**
   * Set the value of the onclick property.
   *
   * @param value the value of the onclick property.
   */
  public void setOnclick(String value)
  {
    setValue(ONCLICK_PROP, value);
  }

  /**
   * Constant that specifies the value of the name of the ondblclick property.
   */
  public static final String ONDBLCLICK_PROP = "ondblclick";
  /**
   * Get the value of the ondblclick property.
   *
   * @return the value of the ondblclick property.
   */
  public String getOndblclick()
  {
    return (String)getValue(ONDBLCLICK_PROP);
  }

⌨️ 快捷键说明

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