Hello together,

we've just recognized some strange behavior when using <wicket:enclosure>
tag.

The scenario:
I have a page that has two labels in it's component hierarchy. In the pages
markup one label is surrounded with an enclosure-tag, and this label is
invisible. The second label was not added to the markup. When I now render
the page I would expect a WicketRuntimeException because of the broken
markup but the page will be rendered successfully.

I would open a ticket in jira, but I want to ensure that I'm not creating a
ticket for an already known bug or expected behavior.

I have a small quickstart for that:

@Test(expected = WicketRuntimeException.class) // fails
public void renderInvisible() throws Exception {
    final WicketTester tester = new WicketTester();
    tester.startPage(new TestPage(false));
    tester.assertRenderedPage(TestPage.class);
    tester.assertVisible("secondLabel"); // true
}

@Test(expected = WicketRuntimeException.class) // success
public void renderVisible() throws Exception {
    final WicketTester tester = new WicketTester();
    tester.startPage(new TestPage(true));
    tester.assertRenderedPage(TestPage.class);
}

public static class TestPage extends WebPage implements
IMarkupResourceStreamProvider {

    public TestPage(boolean labelVisible) {
        add(new Label("label", "invisible").setVisible(labelVisible));
        add(new Label("secondLabel", "WTF?"));
    }

    @Override
    public IResourceStream getMarkupResourceStream(final MarkupContainer
container, final Class<?> containerClass) {
        return new StringResourceStream("<html><body><wicket:enclosure
child=\"label\"><span
wicket:id=\"label\"></span></wicket:enclosure></body></html>");
    }
}

Maybe I could contribute a patch. Do you have any idea where I can find the
cause of this issue?

I've just found out, that unrenderedComponents list in Page#checkRendering
is empty but it must not.

cheers,
Martin

Reply via email to