Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting "The component(s) below failed to render"?

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

like image 385
Snekse Avatar asked Jun 19 '12 21:06

Snekse


3 Answers

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:

  • You are trying to render a Component that is a child of another Component. This means your trying to render a Page or a Panel that is a subclass of a another Page or Panel.
    • e.g. Within a Page you try to call add(new ChildPanel("myChildPanel"));
  • The Component you are extending has defined and add Components with it's own markup
    • e.g. Within AbstractParentPanel you call add(new Label("myCommonLabel"));
  • The markup in the child Component failed to included some required Wicket XHTML
    • e.g. Within 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.
like image 78
Snekse Avatar answered Nov 20 '22 15:11

Snekse


Make sure that you are setting a Wicket component's wicket:id instead of the id! This one gets me all the time.

like image 27
Gaʀʀʏ Avatar answered Nov 20 '22 14:11

Gaʀʀʏ


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.

like image 42
Martin Pletzer Avatar answered Nov 20 '22 14:11

Martin Pletzer