1

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));
        }
S.P. ROOPESH
  • 65
  • 11

1 Answers1

0

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.

martin-g
  • 17,243
  • 2
  • 23
  • 35
  • You mean to say like this? catch (Exception e) { log.error("**** Exception ***********"); setResponsePage(getPage().getPageClass(), getPage().getPageParameters()); log.errorException(e); showErrorMsg(getLocalizer().getString("request.process.page.error", this)); } – S.P. ROOPESH Jun 28 '17 at 06:29
  • martin meant to say `getSession().error(Your error msg );`You have to try like this – soorapadman Jun 28 '17 at 06:31
  • You mean catch (Exception e) { log.error("**** Exception ***********"); setResponsePage(getPage().getPageClass(),getPage().getPageParameters()); log.errorException(e); getSession().error("request.process.page.error"); } – S.P. ROOPESH Jun 28 '17 at 06:47
  • No buddy try like this `getSession().error(showErrorMsg());` – soorapadman Jun 28 '17 at 06:54
  • is it like this? getSession().error(getLocalizer().getString("request.process.page.error", this)); I am really confused buddy, I need to call that userdefined method showErrorMsg(String errorMsg) or not. – S.P. ROOPESH Jun 28 '17 at 08:51
  • @S.P.ROOPESH yes that is fine. – soorapadman Jun 28 '17 at 09:39