1

I was using below configureResponse() in wicket 1.4.9

protected void configureResponse() {
        super.configureResponse();
        WebResponse response = getWebRequestCycle().getWebResponse();
        response.setHeader("Cache-Control", "no-cache, max-age=0,must-revalidate, no-store");
        response.setHeader("Expires", "-1");
        response.setHeader("Pragma", "no-cache");
        response.setCharacterEncoding("text/html; charset=utf-8");
        response.setLocale(new Locale(Constants.USER_LANG_PREF_ENG));

    }

So now in wicket 6 configureResponse() is removed and they replaced with configureResponse(WebResponse response), So I tried to write above code using this method as shown below,

@Override
    protected void configureResponse(WebResponse response) {
    // TODO Auto-generated method stub
    super.configureResponse(response);

    response.setHeader("Cache-Control", "no-cache, max-age=0,must-revalidate, no-store");
    response.setHeader("Expires", "-1");
    response.setHeader("Pragma", "no-cache");
    final String encoding = "text/html" + getMarkupType() + "; charset=utf-8";
    response.setContentType(encoding);
    final Locale originalLocale = getSession().getLocale();
    getSession().setLocale(new Locale(Constants.USER_LANG_PREF_ENG));

}

Can anybody tell me that, this code will work same as previous one or I need to modify again?

S.P. ROOPESH
  • 65
  • 11

1 Answers1

1

It is almost the same but you don't really need it because this is what Wicket would do anyways for you.

Check the implementation of super.configureResponse(response); and org.apache.wicket.markup.html.WebPage#setHeaders(WebResponse).

Apart from this:

  • final Locale originalLocale = getSession().getLocale(); - originalLocale is not used
  • getSession().setLocale(new Locale(Constants.USER_LANG_PREF_ENG)); - this probably should be moved to YourApplication#newSession()
martin-g
  • 17,243
  • 2
  • 23
  • 35
  • Hi Martin, Please help me to fix below line in 6.x--> response.setLocale(new Locale(Constants.USER_LANG_PREF_ENG)); It seems am not setting locale in response .. – S.P. ROOPESH Jun 29 '17 at 10:03
  • You can use `((HttpServletResponse) webResponse.getContainerResponse()).setLocale(...)` – martin-g Jun 29 '17 at 13:43
  • Hi Martin, can u give any idea to solve this issue https://stackoverflow.com/questions/44963393/deployed-web-application-jdk-1-6-wicket-1-4-9-in-jboss-eap-7-0-getting-wicke?noredirect=1#comment77115679_44963393 – S.P. ROOPESH Jul 13 '17 at 05:44