Ing. Pablo Almeida Haro Msc.

ENTITY BEANS UTILIZANDO JSF

 

CREACION DEL PROYECTO WEB

 

*Seleccionar file/new Project/java web/web application

 

*Ingresar el nombre de proyecto y ubicación

 

 

*Seleccionar  servidor y versión de jee

*Seleccionar el framework JSF

 

CREACION DE LA UNIDAD DE PERSISTENCIA

*File/new file/persistence/persistence unit

 

*Colocar el nombre de la unidad de persistencia, proveedor de persistencia y origen de datos

 

CREACION DEL EJB DE ENTIDAD

 

*File/new file/persistence/entity class

*Ingresar nombre de la clase y paquete

*En código debe quedar como sigue a continuación:

 

package pkg_entidad;

 

import java.io.Serializable;

import javax.persistence.Entity;

import javax.persistence.GeneratedValue;

import javax.persistence.GenerationType;

import javax.persistence.Id;

 

@Entity

public class cliente implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id

    @GeneratedValue(strategy = GenerationType.IDENTITY)

    private Long id;

    private String codigo;

    private String nombre;

 

    public String getCodigo() {

        return codigo;

    }

 

    public void setCodigo(String codigo) {

        this.codigo = codigo;

    }

 

    public String getNombre() {

        return nombre;

    }

 

    public void setNombre(String nombre) {

        this.nombre = nombre;

    }

   

    public Long getId() {

        return id;

    }

 

    public void setId(Long id) {

        this.id = id;

    }

 

    @Override

    public int hashCode() {

        int hash = 0;

        hash += (id != null ? id.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 cliente)) {

            return false;

        }

        cliente other = (cliente) object;

        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {

            return false;

        }

        return true;

    }

 

    @Override

    public String toString() {

        return "pkg_entidad.cliente[ id=" + id + " ]";

    }

  

}

 

CREACION DE LA PAGINA JSF A PARTIR DE ENTITY CLASS

*File/new file/ java server faces/jsf pages from entity classes

 

*Seleccionar las clases

*Ingresar los nombres de paquetes para beans de sesión y clases jsf

 

*Analizar los paquetes y clases creados

 

 

CORRER LA APLICACIÓN

 

*Click derecho sobre index.xhtml y run