Example #1
0
  /**
   * Returns a list of {@link KeyValuePair}s that represent the data that will be sent to the server
   * when this form is submitted. This is primarily intended to aid debugging.
   *
   * @param submitElement the element used to submit the form, or <tt>null</tt> if the form was
   *     submitted by JavaScript
   * @return the list of {@link KeyValuePair}s that represent that data that will be sent to the
   *     server when this form is submitted
   */
  private List<NameValuePair> getParameterListForSubmit(final SubmittableElement submitElement) {
    final Collection<SubmittableElement> submittableElements =
        getSubmittableElements(submitElement);

    final List<NameValuePair> parameterList = new ArrayList<>(submittableElements.size());
    for (final SubmittableElement element : submittableElements) {
      for (final NameValuePair pair : element.getSubmitKeyValuePairs()) {
        parameterList.add(pair);
      }
    }

    return parameterList;
  }
Example #2
0
  /**
   * Resets this form to its initial values, returning the page contained by this form's window
   * after the reset. Note that the returned page may or may not be the same as the original page,
   * based on JavaScript event handlers, etc.
   *
   * @return the page contained by this form's window after the reset
   */
  public Page reset() {
    final SgmlPage htmlPage = getPage();
    final ScriptResult scriptResult = fireEvent(Event.TYPE_RESET);
    if (ScriptResult.isFalse(scriptResult)) {
      return scriptResult.getNewPage();
    }

    for (final HtmlElement next : getHtmlElementDescendants()) {
      if (next instanceof SubmittableElement) {
        ((SubmittableElement) next).reset();
      }
    }

    return htmlPage;
  }