Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-1859

Clicking a submit or button in a non-Tapestry Form causes a client exception

    XMLWordPrintableJSON

Details

    Description

      When submitting a html form which was not constructed using the tapestry Form component, tapestry.js still attempts to acquire a Tapestry.FormEventManager, resulting in an uncaught JS exception.

      TML test case:

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns="tapestry:parameter">
      <t:zone t:id="dum" /><!-- make sure js is loaded into page -->
      <head></head>
      <body>
      <form>
      <input type="submit" />
      </form>
      </body>
      </html>

      Excerpt from tapestry.js:

      getFormEventManager : function(form) {
      form = $(form);

      var manager = $T(form).formEventManager;

      if (manager == undefined) {

      throw "No Tapestry.FormEventManager object has been created for form '#

      {id}

      '."
      .interpolate(form);
      }

      return manager;
      },

      is called by:

      setSubmittingElement : function(form, element)

      { form.getFormEventManager() .setSubmittingElement(element); }

      ,

      is called by:

      /*

      • When a submit element is clicked, record the name of the element into
      • the associated form. This is necessary for some Ajax processing, see
      • TAPESTRY-2324.
        *
      • TAP5-1418: Added "type=image" so that they set the submitting element
      • correctly.
        */
        $$("INPUT[type=submit]", "INPUT[type=image]").each(function(element) {
        var t = $T(element);

      if (!t.trackingClicks) {
      element.observe("click", function()

      { $(element.form).setSubmittingElement(element); }

      );

      t.trackingClicks = true;
      }
      });

      The solution is probably to add a check within this last snippet to make sure you are dealing with a tapestry form:

      // skip if this is not a tapestry controlled form
      if (this.form.getInputs("hidden", "t:formdata").size() == 0)
      return;

      The above is taken from elsewhere in tapestry.js.

      Attachments

        Activity

          People

            hlship Howard Lewis Ship
            paul.stanton Paul Stanton
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: