Search in sources :

Example 1 with AbstractRequestWrapperFactory

use of org.apache.wicket.protocol.http.servlet.AbstractRequestWrapperFactory in project wicket by apache.

the class WebApplication method createWebRequest.

/**
 * Pre- and post- configures the {@link WebRequest} created by user override-able
 * {@link #newWebRequest(HttpServletRequest, String)}
 *
 * @param servletRequest
 *            the current HTTP Servlet request
 * @param filterPath
 *            the filter mapping read from web.xml
 * @return a WebRequest object
 */
WebRequest createWebRequest(HttpServletRequest servletRequest, final String filterPath) {
    if (hasFilterFactoryManager()) {
        for (AbstractRequestWrapperFactory factory : getFilterFactoryManager()) {
            servletRequest = factory.getWrapper(servletRequest);
        }
    }
    WebRequest webRequest = newWebRequest(servletRequest, filterPath);
    if (servletRequest.getCharacterEncoding() == null) {
        try {
            if (webRequest.isAjax()) {
                // WICKET-3908, WICKET-1816: Forms submitted with Ajax are always UTF-8 encoded
                servletRequest.setCharacterEncoding(CharEncoding.UTF_8);
            } else {
                String requestEncoding = getRequestCycleSettings().getResponseRequestEncoding();
                servletRequest.setCharacterEncoding(requestEncoding);
            }
        } catch (UnsupportedEncodingException e) {
            throw new WicketRuntimeException(e);
        }
    }
    return webRequest;
}
Also used : AbstractRequestWrapperFactory(org.apache.wicket.protocol.http.servlet.AbstractRequestWrapperFactory) WebRequest(org.apache.wicket.request.http.WebRequest) ServletWebRequest(org.apache.wicket.protocol.http.servlet.ServletWebRequest) WicketRuntimeException(org.apache.wicket.WicketRuntimeException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)1 AbstractRequestWrapperFactory (org.apache.wicket.protocol.http.servlet.AbstractRequestWrapperFactory)1 ServletWebRequest (org.apache.wicket.protocol.http.servlet.ServletWebRequest)1 WebRequest (org.apache.wicket.request.http.WebRequest)1