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.Make sure that you are setting a Wicket component's wicket:id
instead of the id
! This one gets me all the time.
Another possibility is that your page has not any markup. This can accidently happen if the name of your java class does not match the name of your html. I struggled recently with a case-sensitiv situation here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With