コード例 #1
0
ファイル: HtmlForm.java プロジェクト: hanshuai00/MyHtmlUnit
  /**
   * Returns <tt>true</tt> if the specified element gets submitted when this form is submitted,
   * assuming that the form is submitted using the specified submit element.
   *
   * @param element the element to check
   * @param submitElement the element used to submit the form, or <tt>null</tt> if the form is
   *     submitted by JavaScript
   * @return <tt>true</tt> if the specified element gets submitted when this form is submitted
   */
  private boolean isSubmittable(final HtmlElement element, final SubmittableElement submitElement) {
    final String tagName = element.getTagName();
    if (!isValidForSubmission(element, submitElement)) {
      return false;
    }

    // The one submit button that was clicked can be submitted but no other ones
    if (element == submitElement) {
      return true;
    }
    if (element instanceof HtmlInput) {
      final HtmlInput input = (HtmlInput) element;
      final String type = input.getTypeAttribute().toLowerCase(Locale.ENGLISH);
      if ("submit".equals(type)
          || "image".equals(type)
          || "reset".equals(type)
          || "button".equals(type)) {
        return false;
      }
    }
    if ("button".equals(tagName)) {
      return false;
    }

    return true;
  }