Olá,
Nao estou conseguindo ajustar o que estou desenvolvendo... Ele nao inclui os dados e nem visualiza vou postar o Fonte que estou desenvolvendo:
Bean:package pontualtecnologia;
public class Cliente implements java.io.Serializable {
private int codigo;
private String cliente;
public Cliente(){}
public Cliente(int codigo, String cliente){
this.codigo = codigo;
this.cliente = cliente;
}
public void setCodigo(int codigo){
this.codigo = codigo;
}
public int getCodigo(){
return codigo;
}
public void setCliente(String cliente){
this.cliente = cliente;
}
public String getCliente(){
return cliente;
}
}
package relbugs.dao;
import java.util.List;
import pontualtecnologia.Cliente;
public interface InterfaceRelbugs {
public abstract void salvar(Cliente cliente);
public abstract void excluir(Cliente cliente);
public abstract void atualizar(Cliente cliente);
public abstract List todosClientes();
}
package relbugs.dao;
import java.util.List;
import pontualtecnologia.Cliente;
import relbugs.util.ConnectRelbugsFactory;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
public class RelbugsDAO implements InterfaceRelbugs {
private Session session;
public void salvar(Cliente cliente){
session = ConnectRelbugsFactory.getInstance();
Transaction t = null;
try {
t = session.beginTransaction();
session.save(cliente);
t.commit();
} catch (HibernateException e) {
e.printStackTrace();
t.rollback();
}
finally{
session.close();
}
}
public void excluir(Cliente cliente){
session = ConnectRelbugsFactory.getInstance();
Transaction t = null;
try {
t = session.beginTransaction();
session.delete(cliente);
t.commit();
} catch (HibernateException e) {
e.printStackTrace();
t.rollback();
}
finally{
session.close();
}
}
public void atualizar(Cliente cliente){
session = ConnectRelbugsFactory.getInstance();
Transaction t = null;
try {
t = session.beginTransaction();
session.update(cliente);
t.commit();
} catch (HibernateException e) {
e.printStackTrace();
t.rollback();
}
finally{
session.close();
}
}
public List todosClientes(){
session = ConnectRelbugsFactory.getInstance();
List list = session.createQuery("from cliente").list();
return list;
}
}
package relbugs.dao;
/**
*
* @author diego
*/
public class RelbugsDAOException extends Exception{
public RelbugsDAOException(){
}
public RelbugsDAOException(String arg){
super(arg);
}
public RelbugsDAOException(Throwable arg){
super(arg);
}
public RelbugsDAOException(String arg, Throwable arg1){
super(arg, arg1);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="pontualtecnologia.Cliente" table="cliente">
<id name="codigo" column="codigo" type="integer">
<generator class="assigned"/>
</id>
<property name="cliente" type="string"/>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">
org.gjt.mn.mysql.Driver
</property>
<property name="hibernate.connection.url">
jdbc:mysql://localhost/relbugs
</property>
<property name="hibernate.connection.username">
root
</property>
<property name="hibernate.connection.password">
masterkey
</property>
<property name="hibernate.dialect">
org.org.hibernate.dialect.MySQLDialect
</property>
<mapping resource="Cliente.hbm.xml"/>
</session-factory>
</hibernate-configuration>
<%--
Document : mostrarRelbugs
Created on : 20/02/2009, 11:33:04
Author : diego
--%>
<%@ page language="java" contentType="text/html"
pageEncoding="ISO-8859-1"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Atualizar Clientes</title>
</head>
<body>
<f:view>
<h:form id="cadastro">
<h:panelGrid columns="2">
<f:facet name="header">
<h:outputText value="Atualizar Cliente" />
</f:facet>
<h:outputText value="Codigo :" />
<h:inputText size="5" id="codigo"
value="#{clienteView.cliente.codigo}"
readonly="true" />
<h:outputText value="Cliente: " />
<h:inputText size="30" id="cliente"
value="#{clienteView.cliente.cliente}" />
</h:panelGrid>
<h:commandButton value="Atualizar"
action="#{clienteView.update}" />
<h:commandButton value="Redefinir" type="reset" />
<h:commandButton value="Cancelar" action="mostrar" />
</h:form>
</f:view>
</body>
</html>
<%--
Document : formRelbugs
Created on : 20/02/2009, 14:30:37
Author : diego
--%>
<%@ page language="java" contentType="text/html"
pageEncoding="ISO-8859-1"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Cadastro de Clientes</title>
</head>
<body>
<f:view>
<h:form id="cadastro">
<h:panelGrid columns="2">
<f:facet name="header">
<h:outputText value="Cadastro de Clientes"/>
</f:facet>
<h:outputText value="Código: " />
<h:inputText size="5" id="codigo"
value="#{clienteView.cliente.codigo}" />
<h:outputText value="Cliente: " />
<h:inputText size="30" id="cliente"
value="#{clienteView.cliente.cliente}" />
</h:panelGrid>
<br/>
<h:commandButton value="Cadastrar"
action="#{clienteView.create}" />
<h:commandButton value="Limpar" type="reset" />
<h:commandButton value="Cancelar" action="mostrar" />
</h:form>
</f:view>
</body>
</html>
<%--
Document : mostrarRelbugs
Created on : 20/02/2009, 11:33:04
Author : diego
--%>
<%@ page language="java" contentType="text/html"
pageEncoding="ISO-8859-1"
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Listar os Clientes</title>
</head>
<body>
<f:view>
<h:messages />
<h:form>
<h:dataTable value='#{clienteView.todos}'
var='item' border="1"
cellpadding="2" cellspacing="0">
<f:facet name="header">
<h:outputText value="Listar de todos os Clientes"/>
</f:facet>
<h:column>
<f:facet name="header">
<h:outputText value="Código"/>
</f:facet>
<h:commandLink
action="#{clienteView}"
value="#{item.codigo}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Cliente"/>
</f:facet>
<h:outputText value="#{item.cliente}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Excluir Cliente"/>
</f:facet>
</h:column>
<h:commandLink
action="{clienteView.excluir}"
value="Excluir"/>
</h:dataTable>
<br/>
<h:commandLink
action="#{clienteView.novoCliente}"
value="Cadastrar novo Cliente"/>
</h:form>
</f:view>
</body>
</html>
[color=darkblue]O que estar dando errado... Ele sempre me dar a mensagem que é erro interno... sendo q ja fiz tudo certo....[/color]