> public abstract class TestForm extends WebPage { > > public TestForm() { > add(new Label("myDiv", "my div from test form")); => common to > every > concrete page > add(createDivWithComponent("myNewPanel")); => has to be > redefine by > each concrete page > add(createDivWithComponent2("myNewPanel2")); => has to be > redefine > by each concrete page > > } > > protected abstract WebMarkupContainer createDivWithComponent(String > divId); > > protected abstract WebMarkupContainer > createDivWithComponent2(String > divId); > }
An alternative is to have these either provide default/null components or throw WicketRuntimeExceptions. > > <body> > > <div wicket:id="myNewPanel"></div> > <div wicket:id="myNewPanel2"></div> > </body> > > protected WebMarkupContainer createDivWithComponent2(String divId) > { > WebMarkupContainer container = new WebMarkupContainer(divId); > WebMarkupContainer container2 = new WebMarkupContainer("div1"); > container2.add(new Label("label2","My very good label 2")); > container.add(container2); > return container; > } > > } > > <body> > > <div wicket:id="myNewPanel"></div> > <div wicket:id="myNewPanel2"></div> > </body> That markup is missing the "div1" and "label2" markup, but it does not get that far because > And this is the error message I get : WicketMessage: 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. [Component id = myDiv] ... this means that there is no markup for the component you added at the start of the parent constructor: add(new Label("myDiv", "my div from test form")); - Tor Iver