I am developing web app using PrimeFaces and postgresql.
I have some forms which are related to the database. The project need to work with cyrillic characters. So when I fill some characters in the text field the cyrillic is ok but when I click the button and the form reloads I see some garbage characters.
I am using tomcat as a server and I am developing the app locally on my computer.
Here my faces-config.xml file
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
version="2.2">
<application>
<message-bundle>
bg_messages
</message-bundle>
<locale-config>
<default-locale>bg_BG</default-locale>
<supported-locale>bg</supported-locale>
</locale-config>
</application>
</faces-config>
On the xhtml pages I have
<?xml version="1.0" encoding="UTF-8"?>
The database is OK because when I try to add some cyrillic characters manually they are working. I also have some autocomplete in one of the pages and when I manually add some data in cyrillic in the database and then try the autocomplete it is working fine.
Here is one of my pages:
<h:body>
<h1>Вход</h1>
<h:form>
<h:outputText value="Потребителско име: " />
<p:inputText value="#{USER.username}" />
<br />
<br />
<h:outputText value="Парола: " />
<p:password id="nonFeedback" value="#{USER.password}" />
<br />
<br />
<h:commandButton value="Вход" action="#{USER.login}" target="_self" />
</h:form>
</h:body>
So when I put some cyrillic data into
<p:inputText value="#{USER.username}" />
and then click the button I get garbage strange characters. It's the same with my register form. When I fill the data into the form and submit it again the strange characters are showing and they are stored in the database instead of the real proper data.
Here my register 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:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Home | E-Shopper</title>
<h:outputStylesheet library="css" name="bootstrap.min.css" />
<h:outputStylesheet library="css" name="font-awesome.min.css" />
<h:outputStylesheet library="css" name="prettyPhoto.css" />
<h:outputStylesheet library="css" name="price-range.css" />
<h:outputStylesheet library="css" name="animate.css" />
<h:outputStylesheet library="css" name="main.css" />
<h:outputStylesheet library="css" name="responsive.css" />
<h:outputScript library="js" name="bootstrap.min.js" />
<h:outputScript library="js" name="jquery.scrollUp.min.js" />
<h:outputScript library="js" name="price-range.js" />
<h:outputScript library="js" name="jquery.prettyPhoto.js" />
<h:outputScript library="js" name="main.js" />
<h:link rel="shortcut icon" href="images/ico/favicon.ico"></h:link>
<h:link rel="apple-touch-icon-precomposed" sizes="144x144" href="images/ico/apple-touch-icon-144-precomposed.png"></h:link>
<h:link rel="apple-touch-icon-precomposed" sizes="114x114" href="images/ico/apple-touch-icon-114-precomposed.png"></h:link>
<h:link rel="apple-touch-icon-precomposed" sizes="72x72" href="images/ico/apple-touch-icon-72-precomposed.png"></h:link>
<h:link rel="apple-touch-icon-precomposed" href="images/ico/apple-touch-icon-57-precomposed.png"></h:link>
</h:head>
<h:body>
<div id="main_container_reg">
<h1 class="reg_title">Регистрация</h1>
<h:form>
<h:outputLabel styleClass="labels_reg" for="name" value="Име: " />
<p:inputText styleClass="fields_reg" id="name" value="#{USER.name}"/>
<br/><br/>
<h:outputLabel styleClass="labels_reg" for="lastname" value="Фамилия: " />
<p:inputText styleClass="fields_reg" id="lastname" value="#{USER.surname}" />
<br/><br/>
<h:outputLabel styleClass="labels_reg" for="username" value="Потребителско име: * " />
<p:inputText styleClass="fields_reg" id="username" required="true" value="#{USER.username}" />
<h:panelGrid styleClass="pass_reg" columns="2" id="matchGrid" >
<h:outputLabel styleClass="labels_reg" for="password" value="Парола: *" />
<p:password styleClass="fields_reg" id="password" match="pass_conf" label="Парола" required="true" value="#{USER.password}" />
<h:outputLabel styleClass="labels_reg" for="pass_conf" value="Потвърди парола: *" />
<p:password styleClass="fields_reg" id="pass_conf" value="EditorBean" label="полето за потвърждение" required="true" />
</h:panelGrid>
<br/>
<h:outputLabel styleClass="labels_reg" for="email" value="Електронна поща: * " />
<p:inputText styleClass="fields_reg" id="email" required="true" value="#{USER.email}" />
<br/><br/>
<h:outputLabel styleClass="labels_reg" for="phone" value="Телефон: " />
<p:inputText styleClass="fields_reg" id="phone" value="#{USER.phone}" />
<h:panelGrid styleClass="user_type" columns="2" style="margin-bottom:10px" >
<p:outputLabel value="Тип потребител" />
<br/>
<p:selectOneRadio id="data" binding="#{yesOrNo}" required="true" value="No">
<f:selectItem itemValue="No" itemLabel="Частно Лице" />
<f:selectItem itemValue="Yes" itemLabel="Фирма" />
<p:ajax update="campany_name" />
<p:ajax update="city" />
<p:ajax update="street" />
<p:ajax update="street_number" />
<p:ajax update="zip" />
<p:ajax update="upload" />
</p:selectOneRadio>
</h:panelGrid>
<h:outputLabel styleClass="labels_reg" for="company_name" value="Име на фирма: " />
<p:inputText styleClass="fields_reg" value="#{USER.companyName}" id="campany_name" disabled="#{yesOrNo.value != 'Yes'}" />
<br/> <br/>
<h3 style="margin:0 0 0 15px;">Адрес: </h3>
<br/>
<h:outputLabel styleClass="labels_reg" for="city" value="Град: " />
<p:inputText styleClass="fields_reg" value="#{USER.city}" id="city" disabled="#{yesOrNo.value != 'Yes'}" />
<br/><br/>
<h:outputLabel styleClass="labels_reg" for="street" value="Улица: " />
<p:inputText styleClass="fields_reg" value="#{USER.street}" id="street" disabled="#{yesOrNo.value != 'Yes'}" />
<br/><br/>
<h:outputLabel styleClass="labels_reg" for="street_number" value="Номер на Улица: " />
<p:inputText styleClass="fields_reg" value="#{USER.streetNumber}" id="street_number" disabled="#{yesOrNo.value != 'Yes'}" />
<br/><br/>
<h:outputLabel styleClass="labels_reg" for="zip" value="Пощенски код: " />
<p:inputText styleClass="fields_reg" value="#{USER.zip}" id="zip" disabled="#{yesOrNo.value != 'Yes'}" />
<br/> <br/>
<p:messages id="messages" showDetail="true" autoUpdate="true" />
<p:fileUpload fileUploadListener="#{USER.getImageURL}"
allowTypes="/(\.|\/)(gif|jpe?g|png)$/" sizeLimit="100000"
description="Select Images" disabled="#{yesOrNo.value != 'Yes'}"
id="upload" />
<br />
<br />
<h:form enctype="multipart/form-data">
<p:growl id="messages" showDetail="true" />
<p:commandButton styleClass="reg_button" action="#{USER.addUser}" value="Регистрация" ajax="false"
disabled="false" />
<br />
<br />
</h:form>
</h:form>
</div>
</h:body>
</html>