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

WebSocket request while Ajax request leads to error regarding HtmlHeaderCotnainer

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    Description

      There is a problem with header contribution with leads to a "Cannot replace a component which has not been added: id='header'...." error.

      Short:

      • Add at least two components to an AjaxRequestTarget
      • The (at least) second component must initiate a WebSocket push update of another component in onConfigure/onBeforeRender (maybe others)
      • Exception at the end of ajax request (WebSocket request finishes without problem)

      Long:
      AbstractAjaxResponse iterates all components to update in writeComponents(Response, String).
      For each component writeComponent(Response, String, Component, String) is called in sub class XmlAjaxResponse which calls writeHeaderContribution(Response, Component) of AbstractAjaxResponse.
      This method creates the HtmlHeaderContainer and adds is to the page when rendering of first component added to target starts.
      Second component rendering (onConfigure/onBeforeRender) send a component update via websocket push to the client.
      The websocket request replaces the HtmlHeaderContainer added to the page and at the end of the AbstractAjaxResponse.writeTo(Response, String) to header is again replaced with a default one.
      But this default header is removed on MarkupContainer.detachChildren() method.
      Now the ajax request is "continued" and writeHeaderContribution is called for the second component.
      header is not null in writeHeaderContribution because it was already created when processing the first component, so the header is not added to the page again (remember it was replaced while websocket request).
      Now at the end of writeTo method, wicket tries again to replace the header with a default one (comment there says "restore normal header").
      This leads to an exception: Cannot replace a component which has not been added: id='header'....

      A little notice:
      The error would not happen, if second component would be processed before first component, because then the HeaderContainerItem of the ajax request isn't craeted before the websocket request is finished and so the header is added to the page on creation. So the problem is the removal of the HeaderContainerItem in detachChildren() after websocket request.

      In Wicket 7.4 (the only one i tested, this works without problems)

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            svenmeier Sven Meier
            chrenkot Thomas Chrenko
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment