Wicket
  1. Wicket
  2. WICKET-5104

AjaxSelfUpdatingTimerBehavior in hidden component in ModalWindow causes Ajax Response Error

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.3.0, 6.6.0
    • Fix Version/s: 6.7.0
    • Component/s: None
    • Labels:
      None

      Description

      I have a ModalWindow which shows a panel with a hidden label with an AjaxSelfUpdatingTimerBehavior. When the modal window is shown, the following error occurs in the Wicket Ajax Debug console:

      ERROR: Wicket.Ajax.Call.processEvaluation: Exception evaluating javascript: TypeError: Cannot read property 'label5' of undefined, text: (function()

      {clearTimeout(Wicket.TimerHandles['label5']); delete Wicket.TimerHandles['label5'];}

      )();

      1. fix-WICKET-5104.patch
        0.9 kB
        Cedric Gatay
      2. 5104.zip
        26 kB
        Marios Skounakis

        Issue Links

          Activity

          Marios Skounakis created issue -
          Hide
          Marios Skounakis added a comment -

          Quickstart to reproduce the problem - just click on the link on the home page to open the modal window and cause the error to appear.

          Show
          Marios Skounakis added a comment - Quickstart to reproduce the problem - just click on the link on the home page to open the modal window and cause the error to appear.
          Marios Skounakis made changes -
          Field Original Value New Value
          Attachment 5104.zip [ 12574087 ]
          Hide
          Cedric Gatay added a comment -

          You'll find the patch attached, the problem still exists with Wicket 6.7.0-SNAPSHOT.

          The problem was we were not checking if the head had already been rendered before pushing JavaScript asking to stop the behavior.

          Show
          Cedric Gatay added a comment - You'll find the patch attached, the problem still exists with Wicket 6.7.0-SNAPSHOT. The problem was we were not checking if the head had already been rendered before pushing JavaScript asking to stop the behavior.
          Cedric Gatay made changes -
          Attachment fix-WICKET-5104.patch [ 12575227 ]
          Martin Grigorov made changes -
          Assignee Martin Grigorov [ mgrigorov ]
          Hide
          Martin Grigorov added a comment -

          I cannot reproduce the problem with the attached quickstart.
          The Label is set invisible in the panel constructor thus the Ajax timer behavior is disabled and its #renderHead() is not called at all, so it doesn't contribute the JS which should lead to this error.

          What do I miss ?

          Show
          Martin Grigorov added a comment - I cannot reproduce the problem with the attached quickstart. The Label is set invisible in the panel constructor thus the Ajax timer behavior is disabled and its #renderHead() is not called at all, so it doesn't contribute the JS which should lead to this error. What do I miss ?
          Hide
          Cedric Gatay added a comment -

          For me it happened only the second time the page was rendered. The first display everything was fine, after a second display it was all messed up with the JavaScript error in the Wicket Ajax Debug window

          Show
          Cedric Gatay added a comment - For me it happened only the second time the page was rendered. The first display everything was fine, after a second display it was all messed up with the JavaScript error in the Wicket Ajax Debug window
          Hide
          Martin Grigorov added a comment -

          I just tried again.
          I've opened the modal several times without problem.
          I removed ?pageId from the url to create a new page instance and tried again and there is no error.

          Show
          Martin Grigorov added a comment - I just tried again. I've opened the modal several times without problem. I removed ?pageId from the url to create a new page instance and tried again and there is no error.
          Hide
          Cedric Gatay added a comment -

          My brain hurts me this monday It is not the second page load but the second click on the link to open the modal. I just checked it with the latest 6.7.0-SNAPSHOT.

          Launched quickstart, clicked open, closed the modal, clicked open another time > bam Wicket Ajax Debug fever is on.

          Show
          Cedric Gatay added a comment - My brain hurts me this monday It is not the second page load but the second click on the link to open the modal. I just checked it with the latest 6.7.0-SNAPSHOT. Launched quickstart, clicked open, closed the modal, clicked open another time > bam Wicket Ajax Debug fever is on.
          Hide
          Martin Grigorov added a comment -

          No error here :-/
          I've put breakpoints both at org.apache.wicket.ajax.AbstractAjaxTimerBehavior#stop() and org.apache.wicket.ajax.AbstractAjaxTimerBehavior#renderHead() and they are never called no matter how many times I open and the close the modal.

          Show
          Martin Grigorov added a comment - No error here :-/ I've put breakpoints both at org.apache.wicket.ajax.AbstractAjaxTimerBehavior#stop() and org.apache.wicket.ajax.AbstractAjaxTimerBehavior#renderHead() and they are never called no matter how many times I open and the close the modal.
          Hide
          Martin Grigorov added a comment -

          And yes, I also use master branch.

          Show
          Martin Grigorov added a comment - And yes, I also use master branch.
          Hide
          Cedric Gatay added a comment -

          Hum, I just built the master branch (mvn clean install -Dmaven.test.skip=true) locally, then ran mvn clean jetty:run and could reproduce it. I am using Chrome 28.0.1464.0 dev (the built war is available at the following URL http://cl.ly/1c0C30212e3j). The steps to reproduce are the one I detailed previously.

          Show
          Cedric Gatay added a comment - Hum, I just built the master branch (mvn clean install -Dmaven.test.skip=true) locally, then ran mvn clean jetty:run and could reproduce it. I am using Chrome 28.0.1464.0 dev (the built war is available at the following URL http://cl.ly/1c0C30212e3j ). The steps to reproduce are the one I detailed previously.
          Sven Meier made changes -
          Link This issue is broken by WICKET-4959 [ WICKET-4959 ]
          Hide
          Sven Meier added a comment -

          I can reproduce this issue:

          On second click the first MessageBoxPanel's behavior tries to stop itself (because its owning component is removed). Since the modal window is not visible, it's markup is not present on the currently rendered page.

          Show
          Sven Meier added a comment - I can reproduce this issue: On second click the first MessageBoxPanel's behavior tries to stop itself (because its owning component is removed). Since the modal window is not visible, it's markup is not present on the currently rendered page.
          Hide
          Cedric Gatay added a comment -

          The attached patch fixes this issue, as far as I can tell, a review could be necessary to do it the right way though.

          Show
          Cedric Gatay added a comment - The attached patch fixes this issue, as far as I can tell, a review could be necessary to do it the right way though.
          Hide
          Sven Meier added a comment -

          I would think a test on isVisibleInHierarchy() should suffice.

          Show
          Sven Meier added a comment - I would think a test on isVisibleInHierarchy() should suffice.
          Hide
          Martin Grigorov added a comment -

          Sven: can you reproduce the issue ?
          org.apache.wicket.Component#renderHead(HtmlHeaderContainer) checks whether the component is visible(InHierarchy) and only then calls behavior#renderHead().
          As I said earlier neither org.apache.wicket.ajax.AbstractAjaxTimerBehavior#renderHead() nor org.apache.wicket.ajax.AbstractAjaxTimerBehavior#stop() is called here.
          Please put breakpoints in these methods and attach/paste the stacktraces.

          Show
          Martin Grigorov added a comment - Sven: can you reproduce the issue ? org.apache.wicket.Component#renderHead(HtmlHeaderContainer) checks whether the component is visible(InHierarchy) and only then calls behavior#renderHead(). As I said earlier neither org.apache.wicket.ajax.AbstractAjaxTimerBehavior#renderHead() nor org.apache.wicket.ajax.AbstractAjaxTimerBehavior#stop() is called here. Please put breakpoints in these methods and attach/paste the stacktraces.
          Hide
          Sven Meier added a comment -

          Martin: The issue can easily be reproduced with Cedric instructions:

          Thread [qtp1028384965-18] (Suspended (breakpoint at line 201 in AbstractAjaxTimerBehavior))
          AjaxSelfUpdatingTimerBehavior(AbstractAjaxTimerBehavior).onRemove(Component) line: 201
          Behaviors.onRemove(Component) line: 235
          MessageBoxPanel$1(Component).internalOnRemove() line: 1110
          MessageBoxPanel(MarkupContainer).removeChildren() line: 1590
          MessageBoxPanel(Component).internalOnRemove() line: 1111
          ModalWindow(MarkupContainer).removedComponent(Component) line: 1343
          ModalWindow(MarkupContainer).replace(Component) line: 740
          ModalWindow.setContent(Component) line: 944
          HomePage$1.onClick(AjaxRequestTarget) line: 26
          ...

          As you can see this has nothing to do with #renderHead().

          Show
          Sven Meier added a comment - Martin: The issue can easily be reproduced with Cedric instructions: Thread [qtp1028384965-18] (Suspended (breakpoint at line 201 in AbstractAjaxTimerBehavior)) AjaxSelfUpdatingTimerBehavior(AbstractAjaxTimerBehavior).onRemove(Component) line: 201 Behaviors.onRemove(Component) line: 235 MessageBoxPanel$1(Component).internalOnRemove() line: 1110 MessageBoxPanel(MarkupContainer).removeChildren() line: 1590 MessageBoxPanel(Component).internalOnRemove() line: 1111 ModalWindow(MarkupContainer).removedComponent(Component) line: 1343 ModalWindow(MarkupContainer).replace(Component) line: 740 ModalWindow.setContent(Component) line: 944 HomePage$1.onClick(AjaxRequestTarget) line: 26 ... As you can see this has nothing to do with #renderHead().
          Hide
          Martin Grigorov added a comment -

          Thanks!

          Show
          Martin Grigorov added a comment - Thanks!
          Hide
          Martin Grigorov added a comment -

          Thanks, Cedric!

          Show
          Martin Grigorov added a comment - Thanks, Cedric!
          Martin Grigorov made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 6.7.0 [ 12323964 ]
          Resolution Fixed [ 1 ]
          Hide
          Cedric Gatay added a comment -

          I'm glad it is finally fixed. Looking forward to help fixing more

          Show
          Cedric Gatay added a comment - I'm glad it is finally fixed. Looking forward to help fixing more

            People

            • Assignee:
              Martin Grigorov
              Reporter:
              Marios Skounakis
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development