« Return to Thread: devutils -- A child with id 'debug' already exists

Re: devutils -- A child with id 'debug' already exists

by Max Bowsher-5 :: Rate this Message:

Reply to Author | View in Thread

Ryan McKinley wrote:

> I'm trying out the new devuitls package.
>
> When I:
> - checkout /trunk
> - clean install
> - run examples
> - (from any page)
>    - click on the "Live Sessions Page" link in the debug header
>    - click "Enable request recording"
>
> i get this error:
>
> ERROR - RequestCycle               - A child with id 'debug' already exists:
> [Page class = org.apache.wicket.devutils.inspector.LiveSessionsPage,
> id = 0, version = 1, ajax = 0]
> java.lang.IllegalArgumentException: A child with id 'debug' already exists:
> [Page class = org.apache.wicket.devutils.inspector.LiveSessionsPage,
> id = 0, version = 1, ajax = 0]
> at org.apache.wicket.MarkupContainer.add(MarkupContainer.java:145)
> at org.apache.wicket.devutils.DevUtilsPage.onBeforeRender(DevUtilsPage.java:61)
> at org.apache.wicket.Component.internalBeforeRender(Component.java:1063)
> at org.apache.wicket.Component.beforeRender(Component.java:1097)
> at org.apache.wicket.Component.prepareForRender(Component.java:2242)
> at org.apache.wicket.Component.prepareForRender(Component.java:2269)
> at org.apache.wicket.Page.renderPage(Page.java:893)
> at org.apache.wicket.protocol.http.WebRequestCycle.redirectTo(WebRequestCycle.java:166)
>
>
> Any thoughts?
DevUtilsPage is modifying the component hierarchy in onBeforeRender,
which is not allowed IIUC. This should fix it:


Index: src/main/java/org/apache/wicket/devutils/DevUtilsPage.java
===================================================================
--- src/main/java/org/apache/wicket/devutils/DevUtilsPage.java (revision
779350)
+++ src/main/java/org/apache/wicket/devutils/DevUtilsPage.java (working
copy)
@@ -54,11 +54,14 @@
  public DevUtilsPage(PageParameters parameters) {
  super(parameters);
  }
-
+
+ {
+ add(new DebugBar("debug"));
+ }
+
  @Override
  protected void onBeforeRender() {
  super.onBeforeRender();
- add(new DebugBar("debug"));
  DevelopmentUtilitiesNotEnabledException.check();
  }
 }


Max.



signature.asc (204 bytes) Download Attachment

 « Return to Thread: devutils -- A child with id 'debug' already exists