MrMime
MrMime

Reputation: 715

Wicket - Double redirect

Just a little question. How can I implements a double redirect between three page?

Es.

    public class A extends BasePage{

    public A() {
        super("A");
        setResponsePage(new B());
    }

}

public class B extends BasePage{

    public B() {
        super("B");
        setResponsePage(new C());
    }

}

Wicket just stop at Page B without redirect to page C.

Don't ask why I have to do this this. I only need to know if is possibile even not using setResponsePage.

Thanks

Upvotes: 0

Views: 239

Answers (1)

Willem Mulder
Willem Mulder

Reputation: 13994

Wicket will use the last executed setResponsePage() to determine its redirect-page. In your case, that's setResponsePage(new B()) and not setResponsePage(new C()). Indeed, the latter is executed while constructing B.

If you would do

public class A extends BasePage{

    public A() {
        super("A");
        B pageB = new B();
        setResponsePage(pageB);
        pageB.init();
    }

}

public class B extends BasePage{

    public B() {
        super("B");
    }

    public init() {
        setResponsePage(new C());
    }

}

it should work, and you would get a redirect to C!

Upvotes: 2

Related Questions