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

configureResponse() in Wicket 6.x or 7.x


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?


Solution

  • 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: