Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-4575

AjaxButton / AjaxFormSubmitBehavior behaviour in wicket 1.5

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.5.0, 6.0.0-beta2
    • 1.5.8, 6.0.0-beta3
    • wicket
    • None

    Description

      I've just been going through an upgrade form wicket 1.4 to 1.5 and noticed a big change in the AjaxFormSubmitBehavior.onEvent(AjaxRequestTarget).

      In 1.4 the code would submit the From.onSubmit() first and then fire the AjaxFormSubmitBehavior.onSubmit() event, now this behaviour is reversed to process the AjaxFormSubmitBehavior first.

      I have lots of examples of requiring the AjaxButton to perform "on after submit" ajax events, e.g. Ajax Wizard navigation, closing modals after form submit. These ajax events change the component heirachy so that the form is no longer present, thus never gets submitted e.g. Next button. I have no particular cases where I would want the AjaxButton onSubmit called before the form submit, I'm wondering if there are many at all.

      I'm not sure of the implications of changing the AjaxFormSubmitBehavior logic for other components which use it so I will make a suggestion to modify the AjaxFormSubmitBehaviour's onEvent and onSubmit in the AjaxButton to emulate the original behaviour:

      new AjaxFormSubmitBehavior(form, "onclick") {

      boolean formSubmited;

      protected void onEvent(AjaxRequestTarget target) {
      formSubmited = false;
      super.onEvent(target);
      if (formSubmited)

      { LegacyAjaxButton.this.onSubmit(target, LegacyAjaxButton.this.getForm()); }

      }

      protected void onSubmit(AjaxRequestTarget target)

      { formSubmited = true; LegacyAjaxButton.this.onBeforeSubmit(target, LegacyAjaxButton.this.getForm()); }

      ...

      }

      and add an onBeforeSubmit method to the AjaxButton.

      protected void onBeforeSubmit(AjaxRequestTarget target, Form<?> form) {
      }

      The other possible solution would be to change the IFormSubmitter to have both an onAfterSubmit() and call it in Form.delegateSubmit().

      Just as a side note, I've noticed some other chatter on mailing lists around this (see below) so thought I would raise it.

      AjaxWizard issue:
      http://www.mail-archive.com/users@wicket.apache.org/msg71273.html
      AjaxButton issue:
      http://comments.gmane.org/gmane.comp.java.wicket.user/96947

      Attachments

        Issue Links

          Activity

            People

              cmenzel Carl-Eric Menzel
              jamesmcintosh James McIntosh
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: