I'm having trouble understanding how to inject components into a page so that the page will be easy to unit test later. Say I have a page that contains two panels. I can easily use constructor injection to inject these panels into the page:
class MyPage extends WebPage { @Inject public MyPage(PanelA a, PanelB b) { ... } } The problem is that all Panels require an id during construction.[1] How do I supply the id to my Panels? I could simply construct every PanelA with an id of "panela" and every PanelB with an id of "panel", but that doesn't seem very flexible. What do other people do in this situation? The hope would be to pass mocked panels into the page during unit testing, the separately test each panel. What if instead of a panel it was a button where the onSubmit method must be specified by overriding the method. How does one go about injecting such a component so that it's still easy to test later in unit tests? All thoughts and/or best practices are greatly welcomed. For reference I'm using Guice as my dependency injection framework and GuiceWebApplicationFactory to inject components into pages. Thanks... Bill- [1] http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/markup/html/panel/Panel.html