Repository: wicket Updated Branches: refs/heads/wicket-8.x 2edfa9b09 -> 61c870938
WICKET-6608 Stateless page, mix of queue and add can cause unforseen consequences Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/61c87093 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/61c87093 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/61c87093 Branch: refs/heads/wicket-8.x Commit: 61c8709389cea30975814530f53dd0ae1f1ea592 Parents: 2edfa9b Author: Andrea Del Bene <[email protected]> Authored: Tue Nov 6 15:29:03 2018 +0100 Committer: Andrea Del Bene <[email protected]> Committed: Tue Nov 6 15:29:03 2018 +0100 ---------------------------------------------------------------------- .../handler/PageAndComponentProvider.java | 50 +++++++++++++------- 1 file changed, 32 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/61c87093/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageAndComponentProvider.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageAndComponentProvider.java b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageAndComponentProvider.java index 0638c9b..785c4a7 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageAndComponentProvider.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/request/handler/PageAndComponentProvider.java @@ -158,27 +158,10 @@ public class PageAndComponentProvider extends PageProvider implements IPageAndCo component = page != null ? page.get(componentPath) : null; if (component == null) { - - /* - * on stateless pages it is possible that the component may not yet exist because it - * couldve been created in one of the lifecycle callbacks of this page. Lets invoke - * the callbacks to give the page a chance to create the missing component. - */ - // make sure this page instance was just created so the page can be stateless if (page.isPageStateless()) { - Page p = (Page)page; - p.internalInitialize(); - - // preparation of feedbacks is delayed into the render phase - try (FeedbackDelay delay = new FeedbackDelay(p.getRequestCycle())) { - p.beforeRender(); - p.markRendering(false); - - // note: no invocation of delay.onBeforeRender() - } - component = page.get(componentPath); + component = resolveStatelessPageComponent((Page)page); } } } @@ -191,6 +174,37 @@ public class PageAndComponentProvider extends PageProvider implements IPageAndCo } /** + * On stateless pages it is possible that the component may not yet exist because it + * could have been created in one of the lifecycle callbacks of this page. Lets invoke + * the callbacks to give the page a chance to create the missing component. + **/ + private IRequestableComponent resolveStatelessPageComponent(Page page) + { + //1-first let's try initializing the page + page.internalInitialize(); + + IRequestableComponent component = page.get(componentPath); + + if (component != null) + { + return component; + } + + //2-if component has not been found let's try rendering the page + + // preparation of feedbacks is delayed into the render phase + try (FeedbackDelay delay = new FeedbackDelay(page.getRequestCycle())) + { + page.beforeRender(); + page.markRendering(false); + + // note: no invocation of delay.onBeforeRender() + } + + return page.get(componentPath); + } + + /** * @see org.apache.wicket.core.request.handler.IPageAndComponentProvider#getComponentPath() */ @Override
