do you still have that problem in 1.1?
It should be fixed there. Because we now use for rendering and form input the same encoding that can be set in
ApplicatonSettings the ResponseRequestEncoding

The only problem that can happen now is that the user overrides in the browser the encoding.. But that can't be fixed because the browser doesn't send the encoding that it uses in a header or something like that.

johan



Jan Bares wrote:
Hi,

There is known problem with form parameters encoding and servlets. When you
have utf-8 HTML page with forms, you get back the parameters in utf-8, but
the servlet doesn't know, that the page was rendered in utf-8 and interprets
the parameters in different encoding (don't know exactly which one). You can
fix the problem with servlet filter show bellow (code is from Tomcat I
suppose). I think that Wicket should include the filter in its distribution.
What do you think?

Jan


import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class SetCharacterEncodingFilter implements Filter {

    private static Log log =
LogFactory.getLog(SetCharacterEncodingFilter.class);

    protected String encoding = null;
    protected FilterConfig filterConfig = null;
    protected boolean ignore = true;

    public void destroy() {
        this.encoding = null;
        this.filterConfig = null;
    }

    public void doFilter(
            ServletRequest request,
            ServletResponse response,
            FilterChain chain) throws IOException, ServletException {
        log.info("doFilter, encoding called ...");
        if (false == ignore) {
            if (null != encoding) {
                request.setCharacterEncoding(encoding);
                log.info("doFilter, new encoding setuped.");
            }
        }
        chain.doFilter(request, response);
    }

    public void init(FilterConfig filterConfig) throws ServletException {

        this.filterConfig = filterConfig;
        this.encoding = filterConfig.getInitParameter("encoding");
        String value = filterConfig.getInitParameter("ignore");
        if (null == value) {
            this.ignore = true;
        } else if (value.equalsIgnoreCase("true")) {
            this.ignore = true;
        } else if (value.equalsIgnoreCase("yes")) {
            this.ignore = true;
        } else {
            this.ignore = false;
        }
    }
}

<filter>
<filter-name>setCharacterEncoding</filter-name>
<display-name>Set character encoding</display-name>
<description>
<![CDATA[This filter force character encoding of retrieved parameters.]]>
</description>
<filter-class>
SetCharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>ignore</param-name>
<param-value>false</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>setCharacterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>





-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to