[ https://issues.apache.org/jira/browse/WICKET-6246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15505701#comment-15505701 ]
Thomas Chrenko commented on WICKET-6246: ---------------------------------------- The stackoverflow.com question where it all started: http://stackoverflow.com/questions/39511880/apache-wicket-push-websocket-component-update-while-ajax-request-rendering > WebSocket request while Ajax request leads to error regarding > HtmlHeaderCotnainer > --------------------------------------------------------------------------------- > > Key: WICKET-6246 > URL: https://issues.apache.org/jira/browse/WICKET-6246 > Project: Wicket > Issue Type: Bug > Components: wicket > Affects Versions: 6.24.0 > Reporter: Thomas Chrenko > Labels: header, header-contribution > Attachments: quickstart.zip > > > 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) -- This message was sent by Atlassian JIRA (v6.3.4#6332)