Trying to pass a model from one page to another.
Application.init
getRequestCycleSettings().setRenderStrategy(RequestCycleSettings.RenderStrategy.ONE_PASS_RENDER)
I have two pages, both defined with 3 constructors each. PageOne has a form. OnSubmit is supposed to pass the page model from PageOne to PageTwo.
The call to setResponsePage first calls the constructor WebPage(IModel<?> model) and passes the model, as expected.
But immediately after that, it also calls the WebPage() (noargs) and the WebPage(PageParameters parameters) constructor. As a result, PageTwo gets constructed 3 times and ends up having a null DefaultModel.
How can i tell Wicket to stop after calling the WebPage(IModel<?> model) contructor?
Here is the code:
public class PageOne extends WebPage {
// Similar constructors for PageTwo
public PageOne() {
super();
}
public PageOne(PageParameters p) {
super(p);
}
public PageOne(IModel<?> model) {
super(model);
}
@Override
protected void onInitialize() {
super.onInitialize();
Form<Void> form = new Form<Void>("form") {
@Override
public void onSubmit() {
setResponsePage(new PageTwo((IModel<?>)getDefaultModel()));
}
};
}
}
Thank you
Wicket version is 9.13.0
Application is a Springboot App (springboot version 2.7.11), in case that matters.
I expect setresponsePage to call the right constructor only once and pass the model.
Me too! But I need to debug it to see why this happens.
You could try with: