This is similar to question about charset validation except that some characters (e.g. "żźć") are shown as HTML entities ("żźć") after submit. Strange thing is things like "&" save as "&".
I've already tried Spring's CharacterEncodingFilter and Connector on Tomcat side but that didn't seem to help at all. Database encoding doesn't seem to be a problem as my form is working fine when used with AJAX request and a session bean (as opposed to normal submit and request scope).
Here is a part of my form:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
<h:body>
<ui:composition template="/tpls/main-layout.xhtml">
<ui:define name="content">
<h:form>
...
<p:commandButton value="#{i18n.msg('_Save')}"
action="view" actionListener="#{readerController.save}" ajax="false" />
...
<p:panelGrid>
<p:row>
<p:column><h:outputLabel for="lastName" value="#{i18n.msg('Reader.lastName')}" /></p:column>
<p:column><p:inputText id="lastName" value="#{readerController.currentReader.lastName}" required="true">
<p:ajax update="msg-lastName" event="change" />
<f:validateRegex pattern="#{applicationConfiguration.nameValidationPattern}" />
<f:validateLength maximum="50" />
</p:inputText></p:column>
<p:column><p:message for="lastName" id="msg-lastName" /></p:column>
</p:row>
...
</p:panelGrid>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
EDIT: Just as a clarification - you can replace things like #{i18n.msg('_Save')}
with Save
and #{applicationConfiguration.nameValidationPattern}
with e.g. [^0-9]
.