Why am I getting “The component below could not be displayed”?

When I add a ChildPanel to the page, I get an error message:

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 that the components in question are being added to the markup in my AbstractParentPanel, which my ChildPanel extends. It's strange if I make AbstractParentPanel a non-abstract class, I can add this panel without problems.

Why am I getting this error?

NOTE. I have already found the answer to this question. I am adding it to SO to help others, since I spent more time than I should have for such a simple check. If you were burned by this post and this answer helped you, think about voting this JIRA ticket

+4
source share
3 answers

Always start with the obvious and make sure that wicket:id(s) defined in your markup. If you see an identifier added to your markup, then most likely you have the following scenario:

  • You are trying to display a component that is a child of another component. This means that you are trying to make a page or panel that is a subclass of another page or panel.
    • eg. On the page you are trying to call add(new ChildPanel("myChildPanel"));
  • The component that you are expanding has identified and added components with its own markup
    • eg. In AbstractParentPanel you call add(new Label("myCommonLabel"));
  • Markup in child component Failed to include any required Wicket XHTML
    • eg. Inside ChildPanel.html you forgot to add <wicket:extend> tags or even <wicket:panel> tags, or you have one that does not contain the appropriate components.
+6
source

Make sure you configure the Wicket component wicket:id instead of id ! This person gets me all the time.

+2
source

Another possibility is that there is no markup on your page. This can happen by accident if the name of your java class does not match the name of your html. Recently, I struggled with a situation with a sense of sensitivity.

+2
source

All Articles