good morning everyone.
I have a problem. If I put in AJAX = FALSE <p:commandButton/> data with accents such as (',~,^) are inserted into my database distorted. If I remove the AJAX = FALSE is inserted in my database perfectly. The problem is that if I put my AJAX = FALSE confirmation box appears 2, 3, 4 times on top of one another. Has anyone experienced this? Can you help? Thank you.
error accent (ajax=false)
-
- Posts: 39
- Joined: 21 Jun 2011, 18:41
After some testing, I noticed that the error is related to the update given on the form. But I still have not found a solution. If I remove the update form fields are not cleaned after insertion, even in giving a new bean.
-
- Posts: 39
- Joined: 21 Jun 2011, 18:41
The code:
Code: Select all
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:f="http://java.sun.com/jsf/core">
<ui:composition template="../corpo/layout.xhtml">
<ui:define name="conteudo">
<center><h:form id="comp">
<p:messages id="msg" showDetail="false" autoUpdate="true"></p:messages>
<p:growl showDetail="false"></p:growl>
<p:tabView effect="opacity" effectDuration="normal"
style="border:0px">
<p:tab title="Cadastrar" id="cadastro">
<br></br>
<p:scrollPanel style="width:1160px;height:400px; border:0px">
<p:panel header="Cadastro de Produtos" style=" width: 800px">
<h:panelGrid columns="2">
<p:panel header="Produtos">
<img src="../images/produtos.png" />
</p:panel>
<p:panel style="border:0px">
<table>
<tr>
<td><h:outputText value="Código" /></td>
<td><p:inputText title="Código do Produto" size="20"
value="#{controleProduto.produto.proCodigo}" disabled="true"
style="background: #EBF9FE;" /></td>
<td><h:outputText value="Nome *" /></td>
<td><p:inputText title="Nomenclatura do Produto"
maxlength="60" value="#{controleProduto.produto.proNome}" required="true" requiredMessage="Nome do Produto é obrigatório!" /></td>
</tr>
<tr>
<td><h:outputText value="Descrição" /></td>
</tr>
<tr>
<td colspan="4"><p:inputTextarea style="width:540px;"
title="Breve descrição sobre o produto (opcional)" rows="6"
value="#{controleProduto.produto.proDescricao}" /></td>
</tr>
</table>
</p:panel>
</h:panelGrid>
<p:commandButton value="Inserir" onclick="salvar.show()"
type="button" image="ui-icon ui-icon-disk" />
<p:confirmDialog widgetVar="salvar" header="Confirmação"
message="Deseja inserir este produto?" showEffect="explode"
hideEffect="explode" severity="alert" modal="false">
<p:commandButton value="Sim" update="mensagens, comp, msg"
onclick="salvar.hide()" ajax="false"
actionListener="#{controleProduto.salvar}" />
<p:commandButton value="Não" onclick="salvar.hide()"
type="button" />
</p:confirmDialog>
<p:commandButton value="Apagar" onclick="apagar.show()"
type="button" image="ui-icon ui-icon-trash" />
<p:confirmDialog widgetVar="apagar" header="Confirmação"
message="Deseja apagar este registro?" showEffect="explode"
hideEffect="explode" severity="alert" modal="false">
<p:commandButton value="Sim" update="mensagens, comp, avisos" ajax="false"
onclick="apagar.hide()"
actionListener="#{controleProduto.apagar}" />
<p:commandButton value="Não" onclick="apagar.hide()"
type="button" />
</p:confirmDialog>
</p:panel>
<p:tabView effect="opacity" effectDuration="normal"
style=" width: 800px">
<p:tab title="Categoria do Produto" id="categ">
<p:pickList value="#{controleProduto.categorias}"
var="cat" itemLabel="#{cat.catNome}" itemValue="#{cat.catCodigo}"
converter="categoriaProdutoConverter"
effect="bounce" required="true" requiredMessage="É necessário escolher pelo menos uma Categoria!">
<f:facet name="sourceCaption">Categorias Disponíveis</f:facet>
<f:facet name="targetCaption">Categorias Pertencentes</f:facet>
</p:pickList>
</p:tab>
</p:tabView>
</p:scrollPanel>
</p:tab>
</p:tabView>
</h:form></center>
</ui:define>
</ui:composition>
</html>
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Try a character encoding filter.
-
- Posts: 39
- Joined: 21 Jun 2011, 18:41
Thanks optimus.prime!
To help people who eventually came to pass that follows the code as was done to solve this problem:
Created a java class:
mapped the class created in web.xml:
To help people who eventually came to pass that follows the code as was done to solve this problem:
Created a java class:
Code: Select all
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;
public class RequestEncodeFilter implements Filter {
// FilterConfig object
private FilterConfig filterConfig = null;
// Default constructor
public RequestEncodeFilter() {
System.out
.println("Request response encoder Filter object has been created");
}
// Intitialization method
public void init(FilterConfig filterConfig) {
this.filterConfig = filterConfig;
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// Setting the character set for the request
request.setCharacterEncoding("UTF-8");
// pass the request on
chain.doFilter(request, response);
// Setting the character set for the response
response.setContentType("text/html; charset=UTF-8");
}
public void destroy() {
this.filterConfig = null;
}
}
mapped the class created in web.xml:
Code: Select all
<filter>
<filter-name>requestEncodeFilter</filter-name>
<filter-class>RequestEncodeFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>requestEncodeFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Do not set this:
Code: Select all
response.setContentType("text/html; charset=UTF-8");
-
- Information
-
Who is online
Users browsing this forum: No registered users and 30 guests