Boa Tarde.
Galera é o seguinte tenho um página de cadastro bem simples e uma tela de listagem desses cadastros:
Listagem:
<?xml version='1.0' encoding='ISO-8859-1' ?>
<!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:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<link rel = "stylesheet" type = "text/css" href = "css/default.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
</h:head>
<ui:composition template="index.xhtml">
<ui:define name="conteudo">
<f:view>
<body>
<h:form id="formFormasDeImplementacaoDaAcao">
<p:messages showDetail="true" id="msgs" />
<p:panel header="Formas de Implementacao da Ação">
<p:dataTable id="dtFormasDeImplementacaoDaAcao" var="item" value="#{FormaDeImplementacaoDaAcaoBean.formasDeImplementacaoDaAcao}"
emptyMessage="Não há dados" selection="#{FormaDeImplementacaoDaAcaoBean.formaDeImplementacaoDaAcao}"
selectionMode="single" rowKey="#{item.id}">
<p:column headerText="Código">
#{item.codigo}
</p:column>
<p:column headerText="Descrição">
#{item.descricao}
</p:column>
</p:dataTable>
<br/>
<p:commandButton icon="ui-icon-document" value="Novo" action="#{FormaDeImplementacaoDaAcaoBean.adicionarInicio}" update=":formFormasDeImplementacaoDaAcao"/>
<p:commandButton icon="ui-icon-pencil" value="Editar" action="#{FormaDeImplementacaoDaAcaoBean.editarInicio}" ajax="false"/>
<p:commandButton icon="ui-icon-close" value="Excluir" action="#{FormaDeImplementacaoDaAcaoBean.excluirInicio}" update=":formFormasDeImplementacaoDaAcao:msgs :formFormasDeImplementacaoDaAcao:dlg"/>
<p:dialog id="dlg" widgetVar="confirmation" >
Deseja excluir esse registro?<br/><br/>
<p:commandButton id="confirm" value="Sim" action="#{FormaDeImplementacaoDaAcaoBean.excluirFim}" oncomplete="confirmation.hide()" update=":formFormasDeImplementacaoDaAcao:msgs :formFormasDeImplementacaoDaAcao:dtFormasDeImplementacaoDaAcao"/>
<p:commandButton id="decline" value="Não" onclick="confirmation.hide()" action="#{FormaDeImplementacaoDaAcaoBean.cancelar}" update=":formFormasDeImplementacaoDaAcao:dtFormasDeImplementacaoDaAcao" />
</p:dialog>
</p:panel>
</h:form>
</body>
</f:view>
</ui:define>
</ui:composition>
</html>
Cadastro:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>Forma de Implementação da aço</title>
</head>
<ui:composition template="index.xhtml">
<ui:define name="conteudo">
<f:view>
<body>
<h:form id="formFormaDeImplementcaoDaAcao" >
<p:growl showDetail="true"/>
<center>
<p:panel header="Forma de Implementação da Ação" style="width: 450px;text-align: left">
<h:panelGrid columns="2" >
<h:panelGroup>
<h:outputLabel value="Código*"/><br/>
<p:inputMask value="#{FormaDeImplementacaoDaAcaoBean.formaDeImplementacaoDaAcao.codigo}"
required="true" requiredMessage="O campo códigoérequerido" mask="99" size="5"/>
</h:panelGroup>
<h:panelGroup>
<h:outputLabel value="Descrição*"/><br/>
<p:inputText styleClass="up" value="#{FormaDeImplementacaoDaAcaoBean.formaDeImplementacaoDaAcao.descricao}"
required="true" requiredMessage="O campo descriçãoérequerido" size="40"/>
</h:panelGroup>
</h:panelGrid>
<hr/>
<p:commandButton icon="ui-icon-disk" value="Gravar" action="#{FormaDeImplementacaoDaAcaoBean.adicionarEditarFim}" ajax="false"/>
<p:commandButton icon="ui-icon-cancel" value="Cancelar" action="#{FormaDeImplementacaoDaAcaoBean.cancelar}" immediate="true" ajax="false"/>
</p:panel>
</center>
</h:form>
</body>
</f:view>
</ui:define>
</ui:composition>
</html>
E meu código para salvar:
public String adicionarEditarFim() {
formaDeImplementacaoDaAcaoDAO.salvarOuAtualizar(formaDeImplementacaoDaAcao);
formaDeImplementacaoDaAcao = new FormaDeImplementacaoDaAcao();
formasDeImplementacaoDaAcao = null;
return "FormasDeImplementacaoDaAcao";
}
O Problema é que depois de salvar um registro, se eu der um F5 para atualizar a página de listagem
ele gera uma nova linha no banco com o ultimo registro salvo, ou seja, ele duplica o ultimo registro que foi salvo.