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

Reply via email to