Well, new P2() is executed _before_ it's result (a P2 instance) is passed to setResponsePage(), so this behavior is perfectly normal: setResponsePage( new P3() ) is executed before the resulting P2 instance is passed to setResponsePage().
Timeline: 1. new P2() is executed 2. P2 constructor is called, which calls setResponsePage( new P3() ) 3. P2 constructor returns a P2 instance, which is used as input in the first setResponsePage() call As you can see, the final call to setResponsePage() wins, P2 in this case The reason that setResponsePage( P2.class ) does result in P3 being rendered is also logical: it results in wicket instantiating P2.class _after_ setResponsePage( P2.class ) is called. Timeline: 1. setResponsePage( P2.class ) 2. wicket calls the P2 constructor, which calls setResponsePage( new P3() ) As you can see, in this case the final call to setResponsePage() is in the P2 constructor, so it "wins". By throwing a RestartResponseException, setResponsePage( [P2 class instance] ) is never executed, since the exception breaks out of the code. Bas Ryan-117 wrote: > > Throwing RestartResponseException works as expected, but I'm still not > sure if the setResponsePage behavior is correct... > > On Wed, Oct 28, 2009 at 11:52:09AM -0600, Ryan exclaimed: > >>If you have a page,P1, with a form which has an onSubmit() that calls >>setResponsePage(new P2()) and the constructor in P2 calls >>setResponsePage(new P3()) the page that is rendered is P2. >> >>However, P3 is rendered if the onSubmit calls setResponsePage(P2.class) >>and the P2 constructor calls setResponsePage(P3.class). >> >>Is this a bug or am I missing something? >> >>Thanks, >>Ryan >> >>--------------------------------------------------------------------- >>To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >>For additional commands, e-mail: users-h...@wicket.apache.org >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > > -- View this message in context: http://www.nabble.com/setResponsePage-chaining-tp26099119p26104397.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org