Wicket
  1. Wicket
  2. WICKET-5209

NPE when using ComponentRenderer.renderComponent on a panel with <wicket:enclosure>

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.8.0
    • Fix Version/s: 6.9.0, 7.0.0-M1
    • Component/s: wicket
    • Labels:
      None

      Description

      Hi,

      Consider this example:
      <wicket:panel>
      <wicket:enclosure child="externalLink">
      <a wicket:id="externalLink">Link</a>
      </wicket:enclosure>
      </wicket:panel>

      When trying to render such a panel with ComponentRenderer.renderComponent, a NPE is thrown because Wicket try to render Enclosure without initializing it.

      Root cause:
      java.lang.NullPointerException
      at org.apache.wicket.markup.html.internal.Enclosure.isVisible(Enclosure.java:143)
      at org.apache.wicket.Component.determineVisibility(Component.java:4363)
      at org.apache.wicket.Component.internalBeforeRender(Component.java:916)
      at org.apache.wicket.Component.beforeRender(Component.java:991)
      at org.apache.wicket.Component.internalPrepareForRender(Component.java:2214)
      at org.apache.wicket.Component.render(Component.java:2303)
      at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1390)
      at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1554)
      at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1529)
      at org.apache.wicket.MarkupContainer.renderAssociatedMarkup(MarkupContainer.java:689)
      at org.apache.wicket.markup.html.panel.AssociatedMarkupSourcingStrategy.renderAssociatedMarkup(AssociatedMarkupSourcingStrategy.java:76)
      at org.apache.wicket.markup.html.panel.PanelMarkupSourcingStrategy.onComponentTagBody(PanelMarkupSourcingStrategy.java:112)
      at org.apache.wicket.Component.internalRenderComponent(Component.java:2549)
      ... 29 more

      See the attached quickstart.

      I've looked a little into it, and it seems that RenderPage (used by ComponentRenderer to render components) is never initialized.
      Therefore the panel's children are never initialized too (see MarkupContainer l.930), and this causes Enclosure to have a null childComponent.

      Thanks.

        Activity

        GLEIZES Stephane created issue -
        Hide
        GLEIZES Stephane added a comment -

        See TestComponentRenderer in the quickstart.

        Show
        GLEIZES Stephane added a comment - See TestComponentRenderer in the quickstart.
        GLEIZES Stephane made changes -
        Field Original Value New Value
        Attachment component-renderer-enclosure-test-case.tar.gz [ 12585008 ]
        Martin Grigorov made changes -
        Assignee Martin Grigorov [ mgrigorov ]
        Martin Grigorov made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 6.9.0 [ 12324357 ]
        Fix Version/s 7.0.0 [ 12322958 ]
        Resolution Fixed [ 1 ]
        Hide
        Guillaume Smet added a comment -

        Thanks Martin.

        FYI, we now use this feature a lot to generate HTML emails and PDF files using XHTMLRenderer.

        Show
        Guillaume Smet added a comment - Thanks Martin. FYI, we now use this feature a lot to generate HTML emails and PDF files using XHTMLRenderer.
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        11h 47m 1 Martin Grigorov 28/May/13 21:15

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            GLEIZES Stephane
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development