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

MarkupContainer.toString(true) fails with MarkupNotFoundException if the call is made in the component constructor

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5-RC7
    • Fix Version/s: 1.5.1
    • Component/s: wicket
    • Labels:
      None

      Description

      org.apache.wicket.MarkupContainer.toString(boolean) uses "if (getMarkup() != null)" to decide whether to write something for the markup but since recently Component#getMarkup() throws MarkupNotFoundException when there is no markup and doesn't return null.

        Activity

        Hide
        mgrigorov Martin Grigorov added a comment -

        The stack trace:

        Caused by: org.apache.wicket.markup.MarkupNotFoundException: Can not determine Markup. Component is not yet connected to a parent. [WebMarkupContainer [Component id = c1]]
        at org.apache.wicket.Component.getMarkup(Component.java:731)
        at org.apache.wicket.MarkupContainer.toString(MarkupContainer.java:867)
        at org.apache.wicket.Component.<init>(Component.java:678)
        at org.apache.wicket.MarkupContainer.<init>(MarkupContainer.java:118)
        at org.apache.wicket.markup.html.WebMarkupContainer.<init>(WebMarkupContainer.java:49)
        at org.apache.wicket.markup.html.WebMarkupContainer.<init>(WebMarkupContainer.java:41)
        at com.mycompany.HomePage.<init>(HomePage.java:17)
        ...

        Show
        mgrigorov Martin Grigorov added a comment - The stack trace: Caused by: org.apache.wicket.markup.MarkupNotFoundException: Can not determine Markup. Component is not yet connected to a parent. [WebMarkupContainer [Component id = c1] ] at org.apache.wicket.Component.getMarkup(Component.java:731) at org.apache.wicket.MarkupContainer.toString(MarkupContainer.java:867) at org.apache.wicket.Component.<init>(Component.java:678) at org.apache.wicket.MarkupContainer.<init>(MarkupContainer.java:118) at org.apache.wicket.markup.html.WebMarkupContainer.<init>(WebMarkupContainer.java:49) at org.apache.wicket.markup.html.WebMarkupContainer.<init>(WebMarkupContainer.java:41) at com.mycompany.HomePage.<init>(HomePage.java:17) ...
        Hide
        mgrigorov Martin Grigorov added a comment -

        I suggest to move the entry for markup from MarkupContainer.toString(boolean) to Component.toString(boolean) and use 'markup' variable directly.

        Show
        mgrigorov Martin Grigorov added a comment - I suggest to move the entry for markup from MarkupContainer.toString(boolean) to Component.toString(boolean) and use 'markup' variable directly.
        Hide
        bitstorm Andrea Del Bene added a comment -

        +1 for going with the proposed solution. I attach a possible patch.

        Show
        bitstorm Andrea Del Bene added a comment - +1 for going with the proposed solution. I attach a possible patch.
        Hide
        mgrigorov Martin Grigorov added a comment -

        Thanks Andrea!
        I extended even more your patch + a test.

        Show
        mgrigorov Martin Grigorov added a comment - Thanks Andrea! I extended even more your patch + a test.

          People

          • Assignee:
            mgrigorov Martin Grigorov
            Reporter:
            mgrigorov Martin Grigorov
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development