Wicket
  1. Wicket
  2. WICKET-4071

AjaxIndicatorAppender removes itself immediately when added via ajax

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.0
    • Fix Version/s: 1.5.3
    • Component/s: wicket-extensions
    • Labels:
      None

      Description

      When addding/replacing IndicatingAjaxLink's using ajax in Wicket 1.5.0 it's indicator markup is directly removed when parsing the ajax response. The AjaxIndicatorAppender renders a bit of javascript to the response (when it is an ajax request) to remove previous indicators from the dom (see issue WICKET-722) but in 1.5.0 the execution order of the javascript is different, causing the indicator markup to be added first and the javascript to remove previous versions of the indicator to be run next and thus removing the newly added indicator.

      De ajax debug windows shows that the component is replaced first and then the javascript is run. In 1.4.18 ajax logging shows the javascript run first and then the component gets replaced, resulting in correct behavior.

      1. WICKET-4071.patch
        1.0 kB
        Martin Grigorov
      2. myproject.zip
        24 kB
        SoulSpirit
      3. myproject.rar
        21 kB
        Igor Vaynberg
      4. hideIndicator.patch
        0.8 kB
        Andrea Del Bene
      5. cancelRenderHead.patch
        1 kB
        Andrea Del Bene

        Issue Links

          Activity

          Hide
          Martin Grigorov added a comment -

          Can you try this patch ?
          Or provide a quickstart to test it myself.
          Thanks!

          Show
          Martin Grigorov added a comment - Can you try this patch ? Or provide a quickstart to test it myself. Thanks!
          Hide
          Dries Schulten added a comment -

          The patch doesn't fix it, the javascript stil runs after component replace has finished, thus deleting the newly added indicator... So I changed it to prependJavaScript, but the scripts that are added via prepend don't get renderd.

          Show
          Dries Schulten added a comment - The patch doesn't fix it, the javascript stil runs after component replace has finished, thus deleting the newly added indicator... So I changed it to prependJavaScript, but the scripts that are added via prepend don't get renderd.
          Hide
          Igor Vaynberg added a comment -

          i could not reproduce this with trunk, attaching a quickstart that shows its working...

          Show
          Igor Vaynberg added a comment - i could not reproduce this with trunk, attaching a quickstart that shows its working...
          Hide
          SoulSpirit added a comment -

          I'm encountering the same issue on Wicket 1.5.1, and the patch won't work.
          The problem arises only when I add the container of the "indicated" component to the AjaxRequestTarget. Something like:

          MarkupContainer container = new WebMarkupContainer( "container" );
          FormComponent myIndicatingDropDown = new MyIndicatingDropDown( "dropdown" );
          myIndicatingDropDown.add( new OnChangeAjaxBehavior() {
          protected void onUpdate(AjaxRequestTarget target)

          { target.add(container); }

          });
          container.add( myIndicatingDropDown );

          Show
          SoulSpirit added a comment - I'm encountering the same issue on Wicket 1.5.1, and the patch won't work. The problem arises only when I add the container of the "indicated" component to the AjaxRequestTarget. Something like: MarkupContainer container = new WebMarkupContainer( "container" ); FormComponent myIndicatingDropDown = new MyIndicatingDropDown( "dropdown" ); myIndicatingDropDown.add( new OnChangeAjaxBehavior() { protected void onUpdate(AjaxRequestTarget target) { target.add(container); } }); container.add( myIndicatingDropDown );
          Hide
          Martin Grigorov added a comment -

          Please update the attached quickstart application so that it fails.

          Show
          Martin Grigorov added a comment - Please update the attached quickstart application so that it fails.
          Hide
          SoulSpirit added a comment -

          The 2nd time you change the selection in the dropdown, no indicator appears.

          Show
          SoulSpirit added a comment - The 2nd time you change the selection in the dropdown, no indicator appears.
          Hide
          Andrea Del Bene added a comment -

          Why not simply hide indicator span instead of removing it. See patch. It works well, but I didn't find a good solution to prevent method afterRender writes span in response each time component is rendered.

          Show
          Andrea Del Bene added a comment - Why not simply hide indicator span instead of removing it. See patch. It works well, but I didn't find a good solution to prevent method afterRender writes span in response each time component is rendered.
          Hide
          Ivan Vasilev added a comment - - edited

          The issue is still reproducible with myproject.zip - https://issues.apache.org/jira/secure/attachment/12501060/myproject.zip.

          Show
          Ivan Vasilev added a comment - - edited The issue is still reproducible with myproject.zip - https://issues.apache.org/jira/secure/attachment/12501060/myproject.zip .
          Hide
          Andrea Del Bene added a comment -

          It seems that in the last source's version my proposed patch has been reverted to the previous code.
          Anyway, if you look at class AbstractDefaultAjaxBehavior (method generateCallbackScript) you can see that this class already uses a decorator to generate JavaScript code to hide indicator after ajax request has completed.
          So we shouldn't care about hide/remove indicator inside AjaxIndicatorAppender. See proposed patch.

          PS: if you run Ivan's project with this patch , you may occasionally not see the indicator when you change <select> value. That's because ajax response it's too fast and animated gif is showed and suddenly hidden.

          Show
          Andrea Del Bene added a comment - It seems that in the last source's version my proposed patch has been reverted to the previous code. Anyway, if you look at class AbstractDefaultAjaxBehavior (method generateCallbackScript) you can see that this class already uses a decorator to generate JavaScript code to hide indicator after ajax request has completed. So we shouldn't care about hide/remove indicator inside AjaxIndicatorAppender. See proposed patch. PS: if you run Ivan's project with this patch , you may occasionally not see the indicator when you change <select> value. That's because ajax response it's too fast and animated gif is showed and suddenly hidden.
          Hide
          Martin Grigorov added a comment -

          Replaced target.appendJS() with .prependJS() (related to the change with 'priority-evaluate' done by Igor in another ticket).
          This way both quickstarts attached to this ticket work.

          @Andrea: your solution worked only for myproject.zip (the one with the drop-down).

          Show
          Martin Grigorov added a comment - Replaced target.appendJS() with .prependJS() (related to the change with 'priority-evaluate' done by Igor in another ticket). This way both quickstarts attached to this ticket work. @Andrea: your solution worked only for myproject.zip (the one with the drop-down).

            People

            • Assignee:
              Martin Grigorov
              Reporter:
              Dries Schulten
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development