Wicket
  1. Wicket
  2. WICKET-5101

Could not open second modal window after closing first

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.6.0
    • Fix Version/s: 6.12.0, 7.0.0
    • Component/s: wicket
    • Labels:

      Description

      Precondition: first modal window is opened.
      It has ajax submit form inside.

      After submitting form inside modal I want to open another modal with another content.

      I debugged wicket ajax response and found,
      that script, witch should close first window, closes second instead.

      I attached wicket-ajax-response.js to demonstrate the problem.

      wicket ajax engine correct runs those two functions, but "win.current.close();" at line 16
      actually closes second window, opened at line 40.

      See also
      https://issues.apache.org/jira/browse/WICKET-1576

      1. wicket-ajax-response.js
        1 kB
        Artem Morozov
      2. modalFormClose.zip
        30 kB
        Artem Morozov
      3. WICKET-5101.patch
        3 kB
        Andrea Del Bene

        Issue Links

          Activity

          Hide
          Andrea Del Bene added a comment -

          Applied the solution proposed by Octavian Ciubotaru in issue WICKET-1771.

          Show
          Andrea Del Bene added a comment - Applied the solution proposed by Octavian Ciubotaru in issue WICKET-1771 .
          Hide
          Marek Šabo added a comment - - edited

          Hello, what's the current status of this ticket? The patch doesn't seem to be applied in the Wicket 6 master. Does the problem still exist in latest versions?

          We currently use the snipepts from the patch and we have same issue as WICKET-4695 (undefined win.current inside the deferred function in IE8).

          Thanks

          Show
          Marek Šabo added a comment - - edited Hello, what's the current status of this ticket? The patch doesn't seem to be applied in the Wicket 6 master. Does the problem still exist in latest versions? We currently use the snipepts from the patch and we have same issue as WICKET-4695 (undefined win.current inside the deferred function in IE8). Thanks
          Hide
          Andrea Del Bene added a comment -

          Done. I've updated the patch. Both demo app and the quickstart work fine.

          Show
          Andrea Del Bene added a comment - Done. I've updated the patch. Both demo app and the quickstart work fine.
          Hide
          Andrea Del Bene added a comment -

          We can not use namespace Wicket.Window in a page with no ModalWindow. That's why demo app get broken. I'm trying to fix the patch.

          Show
          Andrea Del Bene added a comment - We can not use namespace Wicket.Window in a page with no ModalWindow. That's why demo app get broken. I'm trying to fix the patch.
          Hide
          Martin Grigorov added a comment -

          Your patch breaks the demo in wicket-examples.
          I needed to restore the old logic in org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow#getCloseJavacriptInternal() to make it work, but then the quickstart from this ticket breaks again ... :-/

          Show
          Martin Grigorov added a comment - Your patch breaks the demo in wicket-examples. I needed to restore the old logic in org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow#getCloseJavacriptInternal() to make it work, but then the quickstart from this ticket breaks again ... :-/
          Hide
          Martin Grigorov added a comment - - edited

          Removing setTimeout() from Wicket.Window.close() doesn't help in this case.

          Show
          Martin Grigorov added a comment - - edited Removing setTimeout() from Wicket.Window.close() doesn't help in this case.
          Hide
          Andrea Del Bene added a comment -

          Well, JQuery deferred can actually solve this issue and It can be also applied to 6.x branch. I've attached a patch with a possible solution. However I would also consider to remove setTimeOut from function Wicket.Window.close and test it with all main browser. This solution would reduce the complexity of modal.js instead of increasing it.

          Show
          Andrea Del Bene added a comment - Well, JQuery deferred can actually solve this issue and It can be also applied to 6.x branch. I've attached a patch with a possible solution. However I would also consider to remove setTimeOut from function Wicket.Window.close and test it with all main browser. This solution would reduce the complexity of modal.js instead of increasing it.
          Hide
          Martin Grigorov added a comment -

          If it doesn't break the usage of ModalWindows in 6.x then it can be applied even for 6.8.0.

          Show
          Martin Grigorov added a comment - If it doesn't break the usage of ModalWindows in 6.x then it can be applied even for 6.8.0.
          Hide
          Andrea Del Bene added a comment -

          Today I will try to find something for this issue. Can it be considered as part of the roadmap for Wicket 7?

          Show
          Andrea Del Bene added a comment - Today I will try to find something for this issue. Can it be considered as part of the roadmap for Wicket 7?
          Hide
          Martin Grigorov added a comment -

          I have no idea. Matej Knopp wrote this code 5+ years ago. But I guess we can improve this with jQuery.Deferred - i.e. when action1 is complete then execute action2.
          Play with it. If no one fix it earlier then I'll try after 6.7.0 is released.

          Show
          Martin Grigorov added a comment - I have no idea. Matej Knopp wrote this code 5+ years ago. But I guess we can improve this with jQuery.Deferred - i.e. when action1 is complete then execute action2. Play with it. If no one fix it earlier then I'll try after 6.7.0 is released.
          Hide
          Andrea Del Bene added a comment -

          @Artem
          As you pointed out, we have a synchronization problem due to setTimeout. The second form is built without waiting for the first to be destroyed.

          @Martin
          The comment inside function Wicket.Window.close from modal.js says that we can not directly close the window and we must use setTimeOut. Do you know what's wrong with directly closing the modal window?

          Show
          Andrea Del Bene added a comment - @Artem As you pointed out, we have a synchronization problem due to setTimeout. The second form is built without waiting for the first to be destroyed. @Martin The comment inside function Wicket.Window.close from modal.js says that we can not directly close the window and we must use setTimeOut. Do you know what's wrong with directly closing the modal window?
          Hide
          Artem Morozov added a comment -

          I have already made similar workaround in my case.
          Hope you will avoid usage of setTimeout, or improve 'win.close(target);'

          Thanks for attension to this issue!

          Show
          Artem Morozov added a comment - I have already made similar workaround in my case. Hope you will avoid usage of setTimeout, or improve 'win.close(target);' Thanks for attension to this issue!
          Hide
          Andrea Del Bene added a comment -

          @Artem

          In the meantime you can try to close the current window via JavaScript. You should substitute 'first.close(target);' with
          'target.prependJavaScript("Wicket.Window.get().close();");'

          Show
          Andrea Del Bene added a comment - @Artem In the meantime you can try to close the current window via JavaScript. You should substitute 'first.close(target);' with 'target.prependJavaScript("Wicket.Window.get().close();");'
          Hide
          Artem Morozov added a comment - - edited

          Steps for attached demo:

          1. Click link. -> first modal shown
          2. Click button on modal =>

          Expected scenario : first modal closed, second shown
          Actual: first still opened, second not shown.

          Show
          Artem Morozov added a comment - - edited Steps for attached demo: 1. Click link. -> first modal shown 2. Click button on modal => Expected scenario : first modal closed, second shown Actual: first still opened, second not shown.
          Hide
          Martin Grigorov added a comment -

          Please attach a demo application so we can debug and fix it.
          Thanks!

          Show
          Martin Grigorov added a comment - Please attach a demo application so we can debug and fix it. Thanks!
          Hide
          Martin Grigorov added a comment -

          The problem sounds like WICKET-3151.

          Show
          Martin Grigorov added a comment - The problem sounds like WICKET-3151 .

            People

            • Assignee:
              Andrea Del Bene
              Reporter:
              Artem Morozov
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development