Documentos de Académico
Documentos de Profesional
Documentos de Cultura
\glassfish4\glassfish\domains\domain1\lib
De esta manera se crean el pool: connectionPruebaPool y el dataSource: dsPrueba.
Desde Netbeans:
3.- Crear un proyecto web Netbeans:
List.xhtml:
<?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:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="/template.xhtml">
<ui:define name="title">
<h:outputText value="#{bundle.ListPersonasTitle}"></h:outputText>
</ui:define>
<ui:define name="body">
<h:form styleClass="jsfcrud_list_form">
<h:panelGroup id="messagePanel" layout="block">
<h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
</h:panelGroup>
<h:outputText escape="false" value="#{bundle.ListPersonasEmpty}"
rendered="#{personasController.items.rowCount == 0}"/>
<h:panelGroup rendered="#{personasController.items.rowCount > 0}">
<h:outputText value="#{personasController.pagination.pageFirstItem +
1}..#{personasController.pagination.pageLastItem +
1}/#{personasController.pagination.itemsCount}"/>
<h:commandLink action="#{personasController.previous}" value="#{bundle.Previous}
#{personasController.pagination.pageSize}"
rendered="#{personasController.pagination.hasPreviousPage}"/>
<h:commandLink action="#{personasController.next}" value="#{bundle.Next}
#{personasController.pagination.pageSize}"
rendered="#{personasController.pagination.hasNextPage}"/>
<h:dataTable value="#{personasController.items}" var="item" border="0"
cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row"
rules="all" style="border:solid 1px">
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_cedrucpas}"/>
</f:facet>
<h:outputText value="#{item.cedrucpas}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_apellidos}"/>
</f:facet>
<h:outputText value="#{item.apellidos}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_nombres}"/>
</f:facet>
<h:outputText value="#{item.nombres}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_fechaNacimiento}"/>
</f:facet>
<h:outputText value="#{item.fechaNacimiento}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_direccion}"/>
</f:facet>
<h:outputText value="#{item.direccion}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_telefono}"/>
</f:facet>
<h:outputText value="#{item.telefono}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_correo}"/>
</f:facet>
<h:outputText value="#{item.correo}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_lgeCodigo}"/>
</f:facet>
<h:outputText value="#{item.lgeCodigo}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_genero}"/>
</f:facet>
<h:outputText value="#{item.genero}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value=" "/>
</f:facet>
<h:commandLink action="#{personasController.prepareView}"
value="#{bundle.ListPersonasViewLink}"/>
<h:outputText value=" "/>
<h:commandLink action="#{personasController.prepareEdit}"
value="#{bundle.ListPersonasEditLink}"/>
<h:outputText value=" "/>
<h:commandLink action="#{personasController.destroy}"
value="#{bundle.ListPersonasDestroyLink}"/>
</h:column>
</h:dataTable>
</h:panelGroup>
<br />
<h:commandLink action="#{personasController.prepareCreate}"
value="#{bundle.ListPersonasCreateLink}"/>
<br />
<br />
<h:link outcome="/index" value="#{bundle.ListPersonasIndexLink}"/>
</h:form>
</ui:define>
</ui:composition>
</html>
Create.xhtml:
<?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:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="/template.xhtml">
<ui:define name="title">
<h:outputText value="#{bundle.CreatePersonasTitle}"></h:outputText>
</ui:define>
<ui:define name="body">
<h:panelGroup id="messagePanel" layout="block">
<h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
</h:panelGroup>
<h:form>
<h:panelGrid columns="2">
<h:outputLabel value="#{bundle.CreatePersonasLabel_cedrucpas}" for="cedrucpas" />
<h:inputText id="cedrucpas" value="#{personasController.selected.cedrucpas}"
title="#{bundle.CreatePersonasTitle_cedrucpas}" required="true"
requiredMessage="#{bundle.CreatePersonasRequiredMessage_cedrucpas}"/>
<h:outputLabel value="#{bundle.CreatePersonasLabel_apellidos}" for="apellidos" />
<h:inputText id="apellidos" value="#{personasController.selected.apellidos}"
title="#{bundle.CreatePersonasTitle_apellidos}" />
<h:outputLabel value="#{bundle.CreatePersonasLabel_nombres}" for="nombres" />
<h:inputText id="nombres" value="#{personasController.selected.nombres}"
title="#{bundle.CreatePersonasTitle_nombres}" />
<h:outputLabel value="#{bundle.CreatePersonasLabel_fechaNacimiento}"
for="fechaNacimiento" />
<h:inputText id="fechaNacimiento"
value="#{personasController.selected.fechaNacimiento}"
title="#{bundle.CreatePersonasTitle_fechaNacimiento}" />
<h:outputLabel value="#{bundle.CreatePersonasLabel_direccion}" for="direccion" />
<h:inputText id="direccion" value="#{personasController.selected.direccion}"
title="#{bundle.CreatePersonasTitle_direccion}" />
<h:outputLabel value="#{bundle.CreatePersonasLabel_telefono}" for="telefono" />
<h:inputText id="telefono" value="#{personasController.selected.telefono}"
title="#{bundle.CreatePersonasTitle_telefono}" />
<h:outputLabel value="#{bundle.CreatePersonasLabel_correo}" for="correo" />
<h:inputText id="correo" value="#{personasController.selected.correo}"
title="#{bundle.CreatePersonasTitle_correo}" />
<h:outputLabel value="#{bundle.CreatePersonasLabel_lgeCodigo}" for="lgeCodigo" />
<h:inputText id="lgeCodigo" value="#{personasController.selected.lgeCodigo}"
title="#{bundle.CreatePersonasTitle_lgeCodigo}" />
<h:outputLabel value="#{bundle.CreatePersonasLabel_genero}" for="genero" />
<h:inputText id="genero" value="#{personasController.selected.genero}"
title="#{bundle.CreatePersonasTitle_genero}" />
</h:panelGrid>
<br />
<h:commandLink action="#{personasController.create}"
value="#{bundle.CreatePersonasSaveLink}" />
<br />
<br />
<h:commandLink action="#{personasController.prepareList}"
value="#{bundle.CreatePersonasShowAllLink}" immediate="true"/>
<br />
<br />
<h:link outcome="/index" value="#{bundle.CreatePersonasIndexLink}"/>
</h:form>
</ui:define>
</ui:composition>
</html>
Edit.xhtml:
<?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:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="/template.xhtml">
<ui:define name="title">
<h:outputText value="#{bundle.EditPersonasTitle}"></h:outputText>
</ui:define>
<ui:define name="body">
<h:panelGroup id="messagePanel" layout="block">
<h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
</h:panelGroup>
<h:form>
<h:panelGrid columns="2">
<h:outputLabel value="#{bundle.EditPersonasLabel_cedrucpas}" for="cedrucpas" />
<h:inputText id="cedrucpas" value="#{personasController.selected.cedrucpas}"
title="#{bundle.EditPersonasTitle_cedrucpas}" required="true"
requiredMessage="#{bundle.EditPersonasRequiredMessage_cedrucpas}"/>
<h:outputLabel value="#{bundle.EditPersonasLabel_apellidos}" for="apellidos" />
<h:inputText id="apellidos" value="#{personasController.selected.apellidos}"
title="#{bundle.EditPersonasTitle_apellidos}" />
<h:outputLabel value="#{bundle.EditPersonasLabel_nombres}" for="nombres" />
<h:inputText id="nombres" value="#{personasController.selected.nombres}"
title="#{bundle.EditPersonasTitle_nombres}" />
<h:outputLabel value="#{bundle.EditPersonasLabel_fechaNacimiento}"
for="fechaNacimiento" />
<h:inputText id="fechaNacimiento"
value="#{personasController.selected.fechaNacimiento}"
title="#{bundle.EditPersonasTitle_fechaNacimiento}" />
<h:outputLabel value="#{bundle.EditPersonasLabel_direccion}" for="direccion" />
<h:inputText id="direccion" value="#{personasController.selected.direccion}"
title="#{bundle.EditPersonasTitle_direccion}" />
<h:outputLabel value="#{bundle.EditPersonasLabel_telefono}" for="telefono" />
<h:inputText id="telefono" value="#{personasController.selected.telefono}"
title="#{bundle.EditPersonasTitle_telefono}" />
<h:outputLabel value="#{bundle.EditPersonasLabel_correo}" for="correo" />
<h:inputText id="correo" value="#{personasController.selected.correo}"
title="#{bundle.EditPersonasTitle_correo}" />
<h:outputLabel value="#{bundle.EditPersonasLabel_lgeCodigo}" for="lgeCodigo" />
<h:inputText id="lgeCodigo" value="#{personasController.selected.lgeCodigo}"
title="#{bundle.EditPersonasTitle_lgeCodigo}" />
<h:outputLabel value="#{bundle.EditPersonasLabel_genero}" for="genero" />
<h:inputText id="genero" value="#{personasController.selected.genero}"
title="#{bundle.EditPersonasTitle_genero}" />
</h:panelGrid>
<h:commandLink action="#{personasController.update}"
value="#{bundle.EditPersonasSaveLink}"/>
<br />
<br />
<h:link outcome="View" value="#{bundle.EditPersonasViewLink}"/>
<br />
<h:commandLink action="#{personasController.prepareList}"
value="#{bundle.EditPersonasShowAllLink}" immediate="true"/>
<br />
<br />
<h:link outcome="/index" value="#{bundle.EditPersonasIndexLink}" />
</h:form>
</ui:define>
</ui:composition>
</html>
List.xhtml:
<?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:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="/template.xhtml">
<ui:define name="title">
<h:outputText value="#{bundle.ListPersonasTitle}"></h:outputText>
</ui:define>
<ui:define name="body">
<h:form styleClass="jsfcrud_list_form">
<h:panelGroup id="messagePanel" layout="block">
<h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
</h:panelGroup>
<h:outputText escape="false" value="#{bundle.ListPersonasEmpty}"
rendered="#{personasController.items.rowCount == 0}"/>
<h:panelGroup rendered="#{personasController.items.rowCount > 0}">
<h:outputText value="#{personasController.pagination.pageFirstItem +
1}..#{personasController.pagination.pageLastItem +
1}/#{personasController.pagination.itemsCount}"/>
<h:commandLink action="#{personasController.previous}" value="#{bundle.Previous}
#{personasController.pagination.pageSize}"
rendered="#{personasController.pagination.hasPreviousPage}"/>
<h:commandLink action="#{personasController.next}" value="#{bundle.Next}
#{personasController.pagination.pageSize}"
rendered="#{personasController.pagination.hasNextPage}"/>
<h:dataTable value="#{personasController.items}" var="item" border="0"
cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row"
rules="all" style="border:solid 1px">
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_cedrucpas}"/>
</f:facet>
<h:outputText value="#{item.cedrucpas}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_apellidos}"/>
</f:facet>
<h:outputText value="#{item.apellidos}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_nombres}"/>
</f:facet>
<h:outputText value="#{item.nombres}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_fechaNacimiento}"/>
</f:facet>
<h:outputText value="#{item.fechaNacimiento}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_direccion}"/>
</f:facet>
<h:outputText value="#{item.direccion}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_telefono}"/>
</f:facet>
<h:outputText value="#{item.telefono}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_correo}"/>
</f:facet>
<h:outputText value="#{item.correo}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_lgeCodigo}"/>
</f:facet>
<h:outputText value="#{item.lgeCodigo}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{bundle.ListPersonasTitle_genero}"/>
</f:facet>
<h:outputText value="#{item.genero}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value=" "/>
</f:facet>
<h:commandLink action="#{personasController.prepareView}"
value="#{bundle.ListPersonasViewLink}"/>
<h:outputText value=" "/>
<h:commandLink action="#{personasController.prepareEdit}"
value="#{bundle.ListPersonasEditLink}"/>
<h:outputText value=" "/>
<h:commandLink action="#{personasController.destroy}"
value="#{bundle.ListPersonasDestroyLink}"/>
</h:column>
</h:dataTable>
</h:panelGroup>
<br />
<h:commandLink action="#{personasController.prepareCreate}"
value="#{bundle.ListPersonasCreateLink}"/>
<br />
<br />
<h:link outcome="/index" value="#{bundle.ListPersonasIndexLink}"/>
</h:form>
</ui:define>
</ui:composition>
</html>
View.xhtml:
<?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:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="/template.xhtml">
<ui:define name="title">
<h:outputText value="#{bundle.ViewPersonasTitle}"></h:outputText>
</ui:define>
<ui:define name="body">
<h:panelGroup id="messagePanel" layout="block">
<h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
</h:panelGroup>
<h:form>
<h:panelGrid columns="2">
<h:outputText value="#{bundle.ViewPersonasLabel_cedrucpas}"/>
<h:outputText value="#{personasController.selected.cedrucpas}"
title="#{bundle.ViewPersonasTitle_cedrucpas}"/>
<h:outputText value="#{bundle.ViewPersonasLabel_apellidos}"/>
<h:outputText value="#{personasController.selected.apellidos}"
title="#{bundle.ViewPersonasTitle_apellidos}"/>
<h:outputText value="#{bundle.ViewPersonasLabel_nombres}"/>
<h:outputText value="#{personasController.selected.nombres}"
title="#{bundle.ViewPersonasTitle_nombres}"/>
<h:outputText value="#{bundle.ViewPersonasLabel_fechaNacimiento}"/>
<h:outputText value="#{personasController.selected.fechaNacimiento}"
title="#{bundle.ViewPersonasTitle_fechaNacimiento}"/>
<h:outputText value="#{bundle.ViewPersonasLabel_direccion}"/>
<h:outputText value="#{personasController.selected.direccion}"
title="#{bundle.ViewPersonasTitle_direccion}"/>
<h:outputText value="#{bundle.ViewPersonasLabel_telefono}"/>
<h:outputText value="#{personasController.selected.telefono}"
title="#{bundle.ViewPersonasTitle_telefono}"/>
<h:outputText value="#{bundle.ViewPersonasLabel_correo}"/>
<h:outputText value="#{personasController.selected.correo}"
title="#{bundle.ViewPersonasTitle_correo}"/>
<h:outputText value="#{bundle.ViewPersonasLabel_lgeCodigo}"/>
<h:outputText value="#{personasController.selected.lgeCodigo}"
title="#{bundle.ViewPersonasTitle_lgeCodigo}"/>
<h:outputText value="#{bundle.ViewPersonasLabel_genero}"/>
<h:outputText value="#{personasController.selected.genero}"
title="#{bundle.ViewPersonasTitle_genero}"/>
</h:panelGrid>
<br />
<h:commandLink action="#{personasController.destroyAndView}"
value="#{bundle.ViewPersonasDestroyLink}"/>
<br />
<br />
<h:link outcome="Edit" value="#{bundle.ViewPersonasEditLink}"/>
<br />
<h:commandLink action="#{personasController.prepareCreate}"
value="#{bundle.ViewPersonasCreateLink}" />
<br />
<h:commandLink action="#{personasController.prepareList}"
value="#{bundle.ViewPersonasShowAllLink}"/>
<br />
<br />
<h:link outcome="/index" value="#{bundle.ViewPersonasIndexLink}"/>
</h:form>
</ui:define>
</ui:composition>
</html>
PersonaController.java:
package jsf;
import pkprueba.Personas;
import jsf.util.JsfUtil;
import jsf.util.PaginationHelper;
import psa.session.PersonasFacade;
import java.io.Serializable;
import java.util.ResourceBundle;
import javax.ejb.EJB;
import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import javax.faces.model.SelectItem;
@Named("personasController")
@SessionScoped
public class PersonasController implements Serializable {
public PersonasController() {
}
@Override
public int getItemsCount() {
return getFacade().count();
}
@Override
public DataModel createPageDataModel() {
return new ListDataModel(getFacade().findRange(new int[]{getPageFirstItem(),
getPageFirstItem() + getPageSize()}));
}
};
}
return pagination;
}
@FacesConverter(forClass = Personas.class)
public static class PersonasControllerConverter implements Converter {
@Override
public Object getAsObject(FacesContext facesContext, UIComponent component,
String value) {
if (value == null || value.length() == 0) {
return null;
}
PersonasController controller = (PersonasController)
facesContext.getApplication().getELResolver().
getValue(facesContext.getELContext(), null, "personasController");
return controller.getPersonas(getKey(value));
}
@Override
public String getAsString(FacesContext facesContext, UIComponent component,
Object object) {
if (object == null) {
return null;
}
if (object instanceof Personas) {
Personas o = (Personas) object;
return getStringKey(o.getCedrucpas());
} else {
throw new IllegalArgumentException("object " + object + " is of type " +
object.getClass().getName() + "; expected type: " + Personas.class.getName());
}
}
}
}
Personas.java:
package pkprueba;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author Fausto
*/
@Entity
@Table(name = "personas")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Personas.findAll", query = "SELECT p FROM Personas p"),
@NamedQuery(name = "Personas.findByCedrucpas", query = "SELECT p FROM
Personas p WHERE p.cedrucpas = :cedrucpas"),
@NamedQuery(name = "Personas.findByApellidos", query = "SELECT p FROM
Personas p WHERE p.apellidos = :apellidos"),
@NamedQuery(name = "Personas.findByNombres", query = "SELECT p FROM
Personas p WHERE p.nombres = :nombres"),
@NamedQuery(name = "Personas.findByFechaNacimiento", query = "SELECT p
FROM Personas p WHERE p.fechaNacimiento = :fechaNacimiento"),
@NamedQuery(name = "Personas.findByDireccion", query = "SELECT p FROM
Personas p WHERE p.direccion = :direccion"),
@NamedQuery(name = "Personas.findByTelefono", query = "SELECT p FROM
Personas p WHERE p.telefono = :telefono"),
@NamedQuery(name = "Personas.findByCorreo", query = "SELECT p FROM
Personas p WHERE p.correo = :correo"),
@NamedQuery(name = "Personas.findByLgeCodigo", query = "SELECT p FROM
Personas p WHERE p.lgeCodigo = :lgeCodigo"),
@NamedQuery(name = "Personas.findByGenero", query = "SELECT p FROM
Personas p WHERE p.genero = :genero")})
public class Personas implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 10)
@Column(name = "CEDRUCPAS")
private String cedrucpas;
@Size(max = 40)
@Column(name = "APELLIDOS")
private String apellidos;
@Size(max = 40)
@Column(name = "NOMBRES")
private String nombres;
@Size(max = 20)
@Column(name = "FechaNacimiento")
private String fechaNacimiento;
@Size(max = 100)
@Column(name = "Direccion")
private String direccion;
@Size(max = 11)
@Column(name = "Telefono")
private String telefono;
@Size(max = 100)
@Column(name = "CORREO")
private String correo;
@Size(max = 25)
@Column(name = "LGE_CODIGO")
private String lgeCodigo;
@Size(max = 10)
@Column(name = "Genero")
private String genero;
public Personas() {
}
@Override
public int hashCode() {
int hash = 0;
hash += (cedrucpas != null ? cedrucpas.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Personas)) {
return false;
}
Personas other = (Personas) object;
if ((this.cedrucpas == null && other.cedrucpas != null) || (this.cedrucpas != null &&
!this.cedrucpas.equals(other.cedrucpas))) {
return false;
}
return true;
}
@Override
public String toString() {
return "pkprueba.Personas[ cedrucpas=" + cedrucpas + " ]";
}
}
PersonasFacade.java (session).
package psa.session;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import pkprueba.Personas;
/**
*
* @author Fausto
*/
@Stateless
public class PersonasFacade extends AbstractFacade<Personas> {
@PersistenceContext(unitName = "prbPruebaJSFPU")
private EntityManager em;
@Override
protected EntityManager getEntityManager() {
return em;
}
public PersonasFacade() {
super(Personas.class);
}
}
Bundle.properties:
PersistenceErrorOccured=A persistence error occurred.
Previous=Previous
Next=Next
PaginationHelper.java:
package jsf.util;
import javax.faces.model.DataModel;
AbstractFacade.java:
package psa.session;
import java.util.List;
import javax.persistence.EntityManager;
/**
*
* @author Fausto
*/
public abstract class AbstractFacade<T> {
private Class<T> entityClass;
Persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="prbPruebaJSFPU" transaction-type="JTA">
<jta-data-source>jdbc/dsPrueba</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
</persistence>