wicketwicket-1.5wicket-6wicket-1.6wicket-7

setRedirect(true) in wicket 6.x or 7.x


I have code something like this, So how can I write in wicket 6.x or 7.x 1.

catch (Exception e) {
                log.error("**** Exception ***********");
                setRedirect(true);
                log.errorException(e);
                showErrorMsg(getLocalizer().getString("request.process.page.error", this));
            }

2.

if (admin != null && admin.getId().equalsIgnoreCase(aId) == false) {

                    log.error("UserId do not match");
                    setRedirect(true);
                    showErrorMsg(getLocalizer().getString("internal.user.gccverf.auth.failed", this));

                }

I have method like this

private void showErrorMsg(String errorMsg) {
            setResponsePage(new ErrorPage(this.getPage(), getLocalizer().getString("label.applicaiton.error.page", this), errorMsg));
        }

Solution

  • Just remove setRedirect(true);.

    Another way is to replace it with: setResponsePage(getPage().getPageClass(), getPage().getPageParameters()). This will tell Wicket to create a new instance of the current page's class and render it. In this case it is important that showErrorMsg() uses Session#error() otherwise the error won't be available for the next page.