You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Thomas Chrenko (JIRA)" <ji...@apache.org> on 2016/09/20 05:51:20 UTC

[jira] [Updated] (WICKET-6246) WebSocket request while Ajax request leads to error regarding HtmlHeaderCotnainer

     [ https://issues.apache.org/jira/browse/WICKET-6246?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Thomas Chrenko updated WICKET-6246:
-----------------------------------
    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 at the end of the AbstractAjaxResponse.writeTo(Response, String) method 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.

  was:
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 at the end of the
AbstractAjaxResponse.writeTo(Response, String) method 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.


> 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
>
> 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 at the end of the AbstractAjaxResponse.writeTo(Response, String) method 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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)