Al, that is a very helpful reply, thank you! Yes, I have a lot to learn about wicket, but I know a lot more than I did a few days ago, and I like it so far. In my particular case, the page in question is the HomePage, so, since the user has already been there on her way to Page2, I suppose I will always need to create a new instance if I want to show an alert (for example) as the HomePage is visited from Page2's submit (eg user saved some data entered on a Page2 form by hitting submit). I acheived this, albeit by dubious methods (as you kindly pointed out), by including an alert in the <head> of the HomePage if the constructor that takes a message (eg HomePage(String successMessage)) is called using a StringHeaderContributor. I suppose I need to review this. On the other hand, it is still a useful learning exercise, either way, and I will now study your post in detail before I try again, cheers.
Al Maw wrote: > > howzat wrote: >> ...using setResponsePage(new HomePage(showAlert,alertMessage)... >> I have a different url >> http://localhost:8081/wicket/test?wicket:interface=:3:: >> ... >> Is it because the original instance of HomePage is used only if I >> setResponsePage(HomePage.class)? > > You have a misconception regarding how this all works. ;-) > > URLs for pages can only be "bookmarkable" (i.e. stable, > non-session-dependent) if your page has either a zero-arg constructor: > public MyPage() { ... > > Or if it has a constructor that only has a PageParameters object in it: > public MyPage(PageParameters params) { ... > > > To get the user to such a page, with a stable URL, you need to use either: > new BookmarkablePageLink(MyPage.class, params); > > or > setResponsePage(MyPage.class, params); > > > If you use: > setResponsePage(new MyPage()); > > ...then the call to "new MyPage()" creates an instance of your page then > and there, inside the onClick() handler or similar. > > This page you've created is then persisted within the user's session, > and thus the next page hit needs to be to ?wicket:interface=foo so it > can dig out *that particular instance*. > > The difference between this and a bookmarkable page URL is that with a > bookmarkable page URL, the page is only create if the user goes to that > link. In your case, the page is constructed in the submit/click handler > of the form/link in your current page, before the new page view is even > requested. > > So, you should avoid creating pages as you are. > > Instead, go: > setResponsePage( > MyPage.class, > new PageParameters(Collections.singletonMap("alert", "Hello!")) > ); > > Then in your page: > > public void MyPage(PageParameters params) { > String alert = params.getString("alert") > if (alert != null) { > > > Make sense? > > Al > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Wicket-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/wicket-user > > -- View this message in context: http://www.nabble.com/HomePage-url-changes-when-user-returns-from-a-second-wicket-page-tf3732701.html#a10457997 Sent from the Wicket - User mailing list archive at Nabble.com. ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Wicket-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-user
