When I add a ChildPanel to a page, I get an error that states:
org.apache.wicket.WicketRuntimeException:
The component(s) below failed to render.
A common problem is that you have added a component in code
but forgot to reference it in the markup
(thus the component will never be rendered).
1. [Form [Component id = myForm]]
2. [DropDownChoice [Component id = referenceType]]
3. [TextField [Component id = referenceNumber]]
4. [CheckBox [Component id = referenceReqChk]]
5. [ [Component id = saveRefNumButton]]
6. [ [Component id = cancelRefNumButton]]
at org.apache.wicket.Page.checkRendering(Page.java:693)
at org.apache.wicket.Page.onAfterRender(Page.java:849)
at org.apache.wicket.markup.html.WebPage.onAfterRender(WebPage.java:213)
at org.apache.wicket.Component.afterRender(Component.java:950)
at org.apache.wicket.Component.render(Component.java:2298)
at org.apache.wicket.Page.renderPage(Page.java:1041)
at org.apache.wicket.request.handler.render.
WebPageRenderer.renderPage(WebPageRenderer.java:105)
I can clearly see the components in question are added in the markup in my AbstractParentPanel, which my ChildPanel extends. The odd thing is, if I make the AbstractParentPanel a non-abstract class, I'm able to add that panel with no issues.
Why am I getting this error?
NOTE: I have already found the answer to this question. I'm adding it to SO to help others since I wasted more time than I should have for such a simple check. If you got burned by this message and this answer helped you, consider voting up this JIRA ticket
Always start with the obvious and make sure the wicket:id(s)
are defined in your markup. If you see the ID added in your markup, then chances are you have the following scenario:
add(new ChildPanel("myChildPanel"));
AbstractParentPanel
you call add(new Label("myCommonLabel"));
ChildPanel.html
, you forgot to add <wicket:extend>
tags or maybe even <wicket:panel>
tags, or you have them not containing the components in question.