On Thu, Jan 16, 2014 at 12:07 AM, Paul Bors <p...@bors.ws> wrote: > Awsome, thanks! > > One last question, in my tests I keep a collection of page parameters for > my pages. > I've noticed at some point wicket tester (or deeper in the framework, prob. > in the page factory) that the PageParameter instance used had the > parameters combined from different instances. That scared me a bit. > > ie: I have > customConstructors = new HashMap<Class<? extends AdminPage>, > PageParameters>(); > customConstructors.put(PageA.class, new PageParameters().set("pageID", > "-1")); > customConstructors.put(PageB.class, new PageParameters().set("sessionID", > "-2")); > > and then later when running the test: > PageParameters pageParameters = customConstructors.get(pageClass); > if(pageParameters != null) { > log.info("Running " + pageTest.getTestName() + " for " + > pageClass.getName() + " with pageParameters of " + pageParameters); > pageTest.runTest(getTester(), pageClass, > customConstructors.get(pageClass)); > } > > Above log stamenent would print correct, but when in the page constructor > both pageID AND sessionID are present althrough those are 2 different > instances of PageParameters. > > Should I dig more into that? > To me that sounds like a bug :( >
Yes, it is not correct behavior if you use tester.startPage(clazz, parameters). Make a quickstart and attach it to Jira. > > > > > On Wed, Jan 15, 2014 at 2:24 PM, Martin Grigorov <mgrigo...@apache.org > >wrote: > > > AFAIR if there are no request parameters then Wicket first uses the Java > > default constructor (no parameters) if available. > > If there is no such constructor then Wicket constructs an empty > > PageParameters and uses it for the constructor with PageParameters. > > If none are available then an error is thrown. > > > > Consult with DefaultPageFactory.java > > > > Martin Grigorov > > Wicket Training and Consulting > > > > > > On Wed, Jan 15, 2014 at 8:50 PM, Paul Bors <p...@bors.ws> wrote: > > > > > Btw, I just noticed that adding this constructor eliminates the > problem: > > > public MyPage() { > > > this(null); > > > } > > > > > > So I take it Wicket tries to build the page via the > Page(PageParameters) > > > but instead of using a null reference to the PageParameters it builds > an > > > object without any parameters in it. > > > > > > If the default constructor is added, then it can invoke the custom > > > PageParameters constructor with the null reference. > > > I don't recall this behavior. Has this changed recently? > > > > > > > > > On Wed, Jan 15, 2014 at 1:45 PM, Paul Bors <p...@bors.ws> wrote: > > > > > > > Suppose I have a page with the default constructor and with the page > > > > parameter constructor. > > > > > > > > Should my page parameter constructor be called with an empty not null > > > > PageParameter instance when no parameters are provided? Shouldn't the > > > > default constructor be used instead? > > > > > > > > What about in unit tests? > > > > I've seen the tester use the page parameter constructor and pass it a > > > > reference to an empty PageParameters when I invoke > > > > tester.startPage(MyPage.class, null). > > > > > > > > > >