8 changed files with 670 additions and 1 deletions
			
			
		@ -0,0 +1,129 @@ | 
				
			|||
/* | 
				
			|||
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			|||
 * Click nbfs://nbhost/SystemFileSystem/Templates/J2EE/EJB30/StatelessEjbClass.java to edit this template
 | 
				
			|||
 */ | 
				
			|||
package hola.BL; | 
				
			|||
 | 
				
			|||
import hola.dao.PaisDAO; | 
				
			|||
import hola.modelo.Pais; | 
				
			|||
import hola.msg.Mensaje; | 
				
			|||
import java.util.List; | 
				
			|||
import java.util.Optional; | 
				
			|||
import javax.ejb.Stateless; | 
				
			|||
import javax.faces.application.FacesMessage; | 
				
			|||
import javax.faces.context.FacesContext; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * | 
				
			|||
 * @author eduar | 
				
			|||
 */ | 
				
			|||
@Stateless | 
				
			|||
public class PaisBL implements PaisLocal { | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public Mensaje agregar(Pais pais) { | 
				
			|||
        // Comentario de lógica: Método para agregar una marca
 | 
				
			|||
        System.out.println("Llegaste al método de agregar Pais"); | 
				
			|||
        PaisDAO pisDAO = new PaisDAO(); | 
				
			|||
        Mensaje m = null; | 
				
			|||
 | 
				
			|||
        // Validar que los campos requeridos no estén vacíos
 | 
				
			|||
        if (pais.getNombre().isEmpty()) { | 
				
			|||
            System.out.println(Mensaje.CAMPOS_INCOMPLETOS); | 
				
			|||
            // Enviar mensaje de error si algún campo está incompleto
 | 
				
			|||
            return Mensaje.CAMPOS_INCOMPLETOS; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        // Buscar si la pais ya existe en la base de datos
 | 
				
			|||
        Optional<Pais> paisEncontradaOptional = pisDAO.buscarPais(pais); | 
				
			|||
 | 
				
			|||
        if (paisEncontradaOptional.isPresent()) { | 
				
			|||
            // Manejar el caso en el que se encontró al menos un proveedor duplicado
 | 
				
			|||
            paisEncontradaOptional.get(); | 
				
			|||
            addMessage(FacesMessage.SEVERITY_ERROR, "Error", "Elemento duplicado"); | 
				
			|||
            m = Mensaje.ELEMENTO_DUPLICADO; | 
				
			|||
        } else { | 
				
			|||
            // Agregar el proveedor a la base de datos si no está duplicado
 | 
				
			|||
            pisDAO.agregar(pais); | 
				
			|||
            //registroDAO.agregar(registro);
 | 
				
			|||
            m = Mensaje.SIN_ERROR; | 
				
			|||
        } | 
				
			|||
        return m; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public Pais buscarId(Pais pais) { | 
				
			|||
        // Comentario de lógica: Método para buscar una marca por ID
 | 
				
			|||
        PaisDAO paisDAO = new PaisDAO(); | 
				
			|||
        return paisDAO.buscarPorId(pais); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public void eliminarId(Pais pais) { | 
				
			|||
        // Comentario de lógica: Método para eliminar una marca por ID
 | 
				
			|||
        PaisDAO paisDAO = new PaisDAO(); | 
				
			|||
        if (paisDAO.eliminar(pais)) { | 
				
			|||
            System.out.println(Mensaje.SIN_ERROR); | 
				
			|||
        } else { | 
				
			|||
            System.out.println(Mensaje.NO_EXISTE); | 
				
			|||
        } | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public Mensaje editar(Pais pais) { | 
				
			|||
        // Comentario de lógica: Método para editar una marca
 | 
				
			|||
         Mensaje m; | 
				
			|||
        PaisDAO paisDAO = new PaisDAO(); | 
				
			|||
 | 
				
			|||
        // Validar que los campos requeridos no estén vacíos
 | 
				
			|||
        if (pais.getNombre().isEmpty()  | 
				
			|||
                || pais.getStatus() == null) { | 
				
			|||
            // Enviar mensaje de error si algún campo está incompleto
 | 
				
			|||
            m = Mensaje.CAMPOS_INCOMPLETOS; | 
				
			|||
            System.out.println(Mensaje.CAMPOS_INCOMPLETOS); | 
				
			|||
            return m; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
        try { | 
				
			|||
            // Editar el proveedor solo si todas las validaciones son exitosas
 | 
				
			|||
            Optional<Pais> user = paisDAO.buscarPais(pais); | 
				
			|||
            if (user.isPresent()) { | 
				
			|||
 | 
				
			|||
                addMessage(FacesMessage.SEVERITY_ERROR, "Error", "Elemento duplicado"); | 
				
			|||
                m = Mensaje.ELEMENTO_DUPLICADO; | 
				
			|||
            } else { | 
				
			|||
 | 
				
			|||
                if (paisDAO.editar(pais) == true) { | 
				
			|||
                    m = Mensaje.SIN_ERROR; | 
				
			|||
                    System.out.println(Mensaje.SIN_ERROR); | 
				
			|||
                    return m; | 
				
			|||
                } else { | 
				
			|||
                    m = Mensaje.N0_EXISTE; | 
				
			|||
                    System.out.println(Mensaje.NO_EXISTE); | 
				
			|||
                    return m; | 
				
			|||
                } | 
				
			|||
            } | 
				
			|||
        } catch (Exception e) { | 
				
			|||
            // Capturar cualquier excepción que ocurra durante la edición del proveedor
 | 
				
			|||
            m = Mensaje.DATOS_INCORRECTOS; | 
				
			|||
            System.out.println(Mensaje.DATOS_INCORRECTOS); | 
				
			|||
            e.printStackTrace(); | 
				
			|||
        } | 
				
			|||
        return m;  | 
				
			|||
 | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public List<Pais> buscarValidos(boolean estado) { | 
				
			|||
        PaisDAO paisDAO = new PaisDAO(); | 
				
			|||
        List l = paisDAO.buscarValidos(estado); | 
				
			|||
        // Llama al método buscarValidos de ProductoDAO y devuelve la lista resultante
 | 
				
			|||
        System.out.println(l); | 
				
			|||
        return l; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public void addMessage(FacesMessage.Severity severity, String summary, String detail) { | 
				
			|||
        FacesContext.getCurrentInstance().addMessage("MensajePais", new FacesMessage(severity, summary, detail)); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,26 @@ | 
				
			|||
/* | 
				
			|||
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			|||
 * Click nbfs://nbhost/SystemFileSystem/Templates/J2EE/EJB30/SessionLocal.java to edit this template
 | 
				
			|||
 */ | 
				
			|||
package hola.BL; | 
				
			|||
 | 
				
			|||
import hola.modelo.Pais; | 
				
			|||
import hola.msg.Mensaje; | 
				
			|||
import java.util.List; | 
				
			|||
import javax.ejb.Local; | 
				
			|||
 | 
				
			|||
 | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * | 
				
			|||
 * @author eduar | 
				
			|||
 */ | 
				
			|||
@Local | 
				
			|||
public interface PaisLocal { | 
				
			|||
    public Mensaje agregar(Pais pais); | 
				
			|||
    public Pais buscarId(Pais pais); | 
				
			|||
    public void eliminarId(Pais pais); | 
				
			|||
    public Mensaje editar(Pais pais); | 
				
			|||
    public List<Pais> buscarValidos(boolean pais); | 
				
			|||
     | 
				
			|||
} | 
				
			|||
@ -0,0 +1,127 @@ | 
				
			|||
/* | 
				
			|||
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			|||
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 | 
				
			|||
 */ | 
				
			|||
package hola.dao; | 
				
			|||
 | 
				
			|||
import hola.modelo.Marca; | 
				
			|||
import hola.modelo.Pais; | 
				
			|||
import hola.modelo.Usuario; | 
				
			|||
import java.util.List; | 
				
			|||
import java.util.Optional; | 
				
			|||
import javax.persistence.EntityManager; | 
				
			|||
import javax.persistence.EntityManagerFactory; | 
				
			|||
import javax.persistence.Persistence; | 
				
			|||
import javax.persistence.Query; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * | 
				
			|||
 * @author eduar | 
				
			|||
 */ | 
				
			|||
public class PaisDAO { | 
				
			|||
 | 
				
			|||
    private EntityManager em; | 
				
			|||
 | 
				
			|||
    public PaisDAO() { | 
				
			|||
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("si-ejbPU"); | 
				
			|||
        em = emf.createEntityManager(); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
   public void agregar(Pais pais) { | 
				
			|||
        em.getTransaction().begin(); | 
				
			|||
        pais.setStatus(1); | 
				
			|||
        em.persist(pais);//Almacenar en DB
 | 
				
			|||
        em.getTransaction().commit(); | 
				
			|||
 | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public boolean editar(Pais pais) { | 
				
			|||
        if (buscarPorId(pais) == null) { | 
				
			|||
            return false; | 
				
			|||
        } else { | 
				
			|||
            em.getTransaction().begin(); | 
				
			|||
            em.merge(pais);//edita en la base de datos
 | 
				
			|||
            em.getTransaction().commit(); | 
				
			|||
            return true; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public boolean eliminar(Pais pais) { | 
				
			|||
        if (buscarPorId(pais) == null) { | 
				
			|||
            return false; | 
				
			|||
        } else { | 
				
			|||
 | 
				
			|||
            // Iniciar transacción
 | 
				
			|||
            em.getTransaction().begin(); | 
				
			|||
 | 
				
			|||
            // Obtener proveedor actualizado desde la base de datos
 | 
				
			|||
            Pais u = em.find(Pais.class, pais.getId()); | 
				
			|||
 | 
				
			|||
            // Conservar datos existentes
 | 
				
			|||
            pais.setNombre(u.getNombre()); | 
				
			|||
           // Modificar solo el estado
 | 
				
			|||
            pais.setStatus(0); | 
				
			|||
            em.merge(pais); | 
				
			|||
            em.getTransaction().commit(); | 
				
			|||
            return true; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public Pais buscarPorId(Pais pais) { | 
				
			|||
        Query q = em.createNamedQuery("Pais.findById"); | 
				
			|||
        q.setParameter("id", pais.getId()); | 
				
			|||
        if (q.getResultList().isEmpty()) { | 
				
			|||
            return null; | 
				
			|||
        } else { | 
				
			|||
            return (Pais) q.getResultList().get(0); | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public List<Pais> buscarValidos(boolean status) { | 
				
			|||
        Query q = em.createNamedQuery("Pais.findByStatus"); | 
				
			|||
        int s = status ? 1 : 0; | 
				
			|||
        q.setParameter("status", s); | 
				
			|||
        if (s == 1) { | 
				
			|||
            System.out.println("Activos"); | 
				
			|||
        } else { | 
				
			|||
            System.out.println("Inactivos"); | 
				
			|||
        } | 
				
			|||
        return q.getResultList(); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public Pais buscarPorNombre(Pais pais) { | 
				
			|||
        Query q = em.createNamedQuery("Pais.findByNombre"); | 
				
			|||
        q.setParameter("nombre", pais.getNombre()); | 
				
			|||
        if (q.getResultList().isEmpty()) { | 
				
			|||
            return null; | 
				
			|||
        } else { | 
				
			|||
            return (Pais) q.getResultList().get(0); | 
				
			|||
        } | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public Optional<Pais> buscarPais(Pais pais) { | 
				
			|||
 | 
				
			|||
        Query q1 = em.createNamedQuery("Pais.findByNombre"); | 
				
			|||
        q1.setParameter("nombre", pais.getNombre()); | 
				
			|||
        | 
				
			|||
        List<Pais> resultadoNombre = q1.getResultList(); | 
				
			|||
         | 
				
			|||
 | 
				
			|||
        // Verifica si hay resultados para todos los campos
 | 
				
			|||
        if (!resultadoNombre.isEmpty()) { | 
				
			|||
            // Compara si la misma editorial está en los tres resultados
 | 
				
			|||
            Pais paisEncontrado = resultadoNombre.stream() | 
				
			|||
                    .findFirst() | 
				
			|||
                    .orElse(null); | 
				
			|||
 | 
				
			|||
            return Optional.ofNullable(paisEncontrado); | 
				
			|||
        } else { | 
				
			|||
            // Devuelve Optional vacío para indicar ausencia de resultados
 | 
				
			|||
            return Optional.empty(); | 
				
			|||
        } | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,127 @@ | 
				
			|||
/* | 
				
			|||
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 | 
				
			|||
 * Click nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java to edit this template
 | 
				
			|||
 */ | 
				
			|||
package hola.vista; | 
				
			|||
 | 
				
			|||
import hola.BL.PaisLocal; | 
				
			|||
import hola.modelo.Pais; | 
				
			|||
import hola.msg.Mensaje; | 
				
			|||
import static hola.msg.Mensaje.CAMPOS_INCOMPLETOS; | 
				
			|||
import static hola.msg.Mensaje.DATOS_INCORRECTOS; | 
				
			|||
import static hola.msg.Mensaje.ELEMENTO_DUPLICADO; | 
				
			|||
import static hola.msg.Mensaje.SIN_ERROR; | 
				
			|||
import javax.inject.Named; | 
				
			|||
import javax.enterprise.context.SessionScoped; | 
				
			|||
import java.io.Serializable; | 
				
			|||
import java.util.List; | 
				
			|||
import java.util.Locale; | 
				
			|||
import javax.ejb.EJB; | 
				
			|||
import org.primefaces.util.LangUtils; | 
				
			|||
 | 
				
			|||
/** | 
				
			|||
 * | 
				
			|||
 * @author eduar | 
				
			|||
 */ | 
				
			|||
@Named(value = "demoBeanPais") | 
				
			|||
@SessionScoped | 
				
			|||
public class DemoBeanPais implements Serializable { | 
				
			|||
 | 
				
			|||
    @EJB | 
				
			|||
    private PaisLocal paisBL; | 
				
			|||
 | 
				
			|||
    public DemoBeanPais() { | 
				
			|||
    } | 
				
			|||
    private Pais pais = new Pais(); | 
				
			|||
    private String titulo; | 
				
			|||
    private boolean nuevo; | 
				
			|||
 | 
				
			|||
    private List<Pais> filteredCustomers3; | 
				
			|||
 | 
				
			|||
    public List<Pais> getFilteredCustomers3() { | 
				
			|||
        return filteredCustomers3; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public void setFilteredCustomers3(List<Pais> filteredCustomers3) { | 
				
			|||
        this.filteredCustomers3 = filteredCustomers3; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public boolean globalFilterFunction(Object value, Object filter, Locale locale) { | 
				
			|||
        String filterText = (filter == null) ? null : filter.toString().trim().toLowerCase(); | 
				
			|||
        if (LangUtils.isBlank(filterText)) { | 
				
			|||
            return true; | 
				
			|||
        } | 
				
			|||
//BUSCADOR DE CADA CAMPO
 | 
				
			|||
        Pais customer = (Pais) value; | 
				
			|||
        return customer.getNombre().toLowerCase().contains(filterText); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public String agregarPais() { | 
				
			|||
 | 
				
			|||
        pais.setStatus(1); | 
				
			|||
        // limpiarFormulario();
 | 
				
			|||
        Mensaje mensaje = paisBL.agregar(pais); | 
				
			|||
 | 
				
			|||
        switch (mensaje) { | 
				
			|||
            case SIN_ERROR: | 
				
			|||
                pais = new Pais(); | 
				
			|||
                return "Pais.xhtml";//"productoLista?faces-redirect=true"; // Redirecciona a la lista de productos
 | 
				
			|||
            case ELEMENTO_DUPLICADO: | 
				
			|||
                return null; | 
				
			|||
            case CAMPOS_INCOMPLETOS: | 
				
			|||
                return null; | 
				
			|||
            case DATOS_INCORRECTOS: | 
				
			|||
                return null; | 
				
			|||
            default: | 
				
			|||
                return null; | 
				
			|||
        } | 
				
			|||
 | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public List<Pais> getPaises() { | 
				
			|||
        return paisBL.buscarValidos(true); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public Pais getPais() { | 
				
			|||
        return pais; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public void setPais(Pais pais) { | 
				
			|||
        this.pais = pais; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public void prepararEditar(Pais pais) { | 
				
			|||
        nuevo = false; | 
				
			|||
        titulo = "Editar paises"; | 
				
			|||
        this.pais = pais; | 
				
			|||
 | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public String getTitulo() { | 
				
			|||
        return titulo; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public boolean isNuevo() { | 
				
			|||
        return nuevo; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public void preparar() { | 
				
			|||
        nuevo = true; | 
				
			|||
        titulo = "Agregar Pais"; | 
				
			|||
        pais = new Pais(); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public void editarPais() { | 
				
			|||
        paisBL.editar(pais); | 
				
			|||
 | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public void prepararEliminar(Pais pais) { | 
				
			|||
        this.pais = pais; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    public void eliminaPais() { | 
				
			|||
        paisBL.eliminarId(pais); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,114 @@ | 
				
			|||
<?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" | 
				
			|||
      xmlns:p="http://primefaces.org/ui"> | 
				
			|||
    <body> | 
				
			|||
 | 
				
			|||
        <ui:composition template="./template/Principal.xhtml"> | 
				
			|||
 | 
				
			|||
            <ui:define name="top"> | 
				
			|||
                top | 
				
			|||
            </ui:define> | 
				
			|||
 | 
				
			|||
            <ui:define name="left"> | 
				
			|||
                <div class="card"> | 
				
			|||
                    <h:form> | 
				
			|||
                        <p:growl id="messages"/> | 
				
			|||
 | 
				
			|||
                        <p:menubar> | 
				
			|||
                            <p:menuitem value="Agregar" icon="pi pi-fw pi-plus"  | 
				
			|||
                                        action="UsuarioCrear.xhtml" | 
				
			|||
                                        actionListener="#{demoBeanUsuario.preparar()}"/> | 
				
			|||
 | 
				
			|||
                            <p:menuitem value="Departamento" icon="pi pi-fw pi-building " action="Departamento.xhtml"/> | 
				
			|||
                            <p:menuitem value="Marca" icon="pi pi-fw pi-tag" action="Marca.xhtml"/> | 
				
			|||
                            <p:menuitem value="Producto" icon="pi pi-fw pi-shopping-bag" action="Producto.xhtml"/> | 
				
			|||
                            <p:menuitem value="Proveedor" icon="pi pi-fw pi-truck" action="Provedor.xhtml"/> | 
				
			|||
                            <!-- comment      <p:menuitem value="Registro" icon="pi pi-fw pi-book " disabled="true" action="Registro.xhtml"/> --> | 
				
			|||
                            <p:menuitem value="Tipo" icon="pi pi-fw pi-table" action="Tipo.xhtml"/> | 
				
			|||
                            <p:menuitem value="Usuario" icon="pi pi-fw pi-user" disabled="true" action="Usuario.xhtml"/> | 
				
			|||
                            <p:menuitem value="Inicio" icon="pi pi-fw pi-home" action="Menu.xhtml"/> | 
				
			|||
                            <p:divider layout="vertical"/> | 
				
			|||
                        </p:menubar> | 
				
			|||
                    </h:form>  | 
				
			|||
                </div> | 
				
			|||
            </ui:define> | 
				
			|||
 | 
				
			|||
            <ui:define name="right"> | 
				
			|||
                right | 
				
			|||
            </ui:define> | 
				
			|||
 | 
				
			|||
            <ui:define name="content"> | 
				
			|||
                <h:form style="text-align: center; margin-top: 20px;"> | 
				
			|||
 | 
				
			|||
                </h:form> | 
				
			|||
                <f:view> | 
				
			|||
 | 
				
			|||
 | 
				
			|||
                    <h:form> | 
				
			|||
 | 
				
			|||
                        <h3><h:outputText value="Paises"/></h3> | 
				
			|||
 | 
				
			|||
                        <p:dataTable value="#{demoBeanPais.paises}" var="item" | 
				
			|||
                                     widgetVar="paises" | 
				
			|||
                                     emptyMessage="No coincide con ningun registro" | 
				
			|||
                                     filteredValue="#{demoBeanPais.filteredCustomers3}" | 
				
			|||
                                     globalFilterFunction="#{demoBeanPais.globalFilterFunction}"> | 
				
			|||
                            <f:facet name="header"> | 
				
			|||
                                <div class="flex justify-content-end" style="position: absolute; right: 40px; top: 190px; "> | 
				
			|||
                                    <p:inputText id="globalFilter" onkeyup="PF('paises').filter()" style="width:300px" | 
				
			|||
                                                 placeholder="Buscar" /> | 
				
			|||
                                </div> | 
				
			|||
                            </f:facet> | 
				
			|||
                            <p:column style="width: 10px;"> | 
				
			|||
                                <f:facet name="header"> | 
				
			|||
                                    <h:outputText value="Id"/> | 
				
			|||
                                </f:facet> | 
				
			|||
                                <h:outputText value="#{item.id}"/> | 
				
			|||
                            </p:column> | 
				
			|||
                            <p:column> | 
				
			|||
                                <f:facet name="header"> | 
				
			|||
                                    <h:outputText value="Nombre"/> | 
				
			|||
                                </f:facet> | 
				
			|||
                                <h:outputText value="#{item.nombre}"/> | 
				
			|||
                            </p:column> | 
				
			|||
                            <p:column> | 
				
			|||
                                <f:facet name="header"> | 
				
			|||
                                    <h:outputText value="Status"/> | 
				
			|||
                                </f:facet> | 
				
			|||
                                <h:outputText value="#{item.status == 1 ? 'activo':'inactivo'}"/> | 
				
			|||
                            </p:column> | 
				
			|||
                            <p:column> | 
				
			|||
                                <f:facet name="header"> | 
				
			|||
                                    <h:outputText value="Opciones"/> | 
				
			|||
                                </f:facet>                                     | 
				
			|||
                                <p:commandButton action="PaisCrear.xhtml" icon="pi pi-fw pi-pencil" | 
				
			|||
                                                 actionListener="#{demoBeanPais.prepararEditar(item)}" | 
				
			|||
                                                 style="padding: 2px 8px; font-size: 11px; font-weight: bold; color: #3366FF; background-color: #fff; border: 2px solid #3366FF; border-radius: 8px; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); transition: transform 0.3s ease ; margin-right: 6px;" | 
				
			|||
                                                 value="Editar" | 
				
			|||
                                                 ajax="false"/>                                    | 
				
			|||
                                <p:commandButton action="PaisEliminar.xhtml" icon="pi pi-fw pi-trash" | 
				
			|||
                                                 actionListener="#{demoBeanPais.prepararEliminar(item)}"  | 
				
			|||
                                                 value="Eliminar"  | 
				
			|||
                                                 style=" padding: 2px 8px; font-size: 11px; font-weight: bold; color: #990000; background-color: #fff; border: 2px solid #FF0000; border-radius: 8px; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); transition: transform 0.3s ease; margin-right: 6px;" | 
				
			|||
                                                 ajax="false"/> | 
				
			|||
 | 
				
			|||
 | 
				
			|||
                            </p:column> | 
				
			|||
                        </p:dataTable> | 
				
			|||
                    </h:form> | 
				
			|||
                </f:view> | 
				
			|||
 | 
				
			|||
            </ui:define> | 
				
			|||
 | 
				
			|||
            <ui:define name="bottom"> | 
				
			|||
 | 
				
			|||
            </ui:define> | 
				
			|||
 | 
				
			|||
        </ui:composition> | 
				
			|||
 | 
				
			|||
    </body> | 
				
			|||
</html> | 
				
			|||
@ -0,0 +1,84 @@ | 
				
			|||
<?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" | 
				
			|||
      xmlns:p="http://primefaces.org/ui"> | 
				
			|||
 | 
				
			|||
    <body> | 
				
			|||
 | 
				
			|||
        <ui:composition template="./template/Principal.xhtml"> | 
				
			|||
 | 
				
			|||
            <ui:define name="top"> | 
				
			|||
                SISTEMA DE INVENTARIO | 
				
			|||
 | 
				
			|||
            </ui:define> | 
				
			|||
 | 
				
			|||
            <ui:define name="left"> | 
				
			|||
 | 
				
			|||
            </ui:define> | 
				
			|||
 | 
				
			|||
            <ui:define name="right"> | 
				
			|||
 | 
				
			|||
            </ui:define> | 
				
			|||
 | 
				
			|||
            <ui:define name="content"> | 
				
			|||
                <f:view> | 
				
			|||
 | 
				
			|||
 | 
				
			|||
                    <h:form> | 
				
			|||
                        <p:growl id="growl" showDetail="true" for="MensajePais"/> | 
				
			|||
 | 
				
			|||
                        <h1><h:outputText value="#{demoBeanPais.titulo}"/></h1> | 
				
			|||
                        <h:panelGrid columns="3"> | 
				
			|||
 | 
				
			|||
                            <p:outputLabel value="Nombre:" for="nombre" /> | 
				
			|||
                            <p:inputText id="nombre" value="#{demoBeanPais.pais.nombre}"  | 
				
			|||
                                         title="Nombre" | 
				
			|||
                                         required="true" | 
				
			|||
                                         requiredMessage="El campo nombre es obligatorio" | 
				
			|||
                                         validatorMessage="El campo nombre no debe incluir números, debe incluir mínimo 3 letras y máximo 15 letras"> | 
				
			|||
                                <f:validateRegex pattern="[a-zA-Z ]+" /> | 
				
			|||
                                <f:validateLength minimum="3" maximum="15" /> | 
				
			|||
                            </p:inputText> | 
				
			|||
                            <p:message for="nombre" /> | 
				
			|||
                        </h:panelGrid> | 
				
			|||
                        <p:commandButton action="#{demoBeanPais.agregarPais()}"  | 
				
			|||
                                         icon="pi pi-fw pi-check" | 
				
			|||
                                         style="padding: 2px 8px; font-size: 13px; font-weight: bold; color: #3366FF; background-color: #fff; border: 2px solid #3366FF; border-radius: 8px; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); transition: transform 0.3s ease ; margin-right: 6px;" | 
				
			|||
 | 
				
			|||
                                         rendered="#{demoBeanPais.nuevo}" | 
				
			|||
                                         value="Agregar"  | 
				
			|||
                                         update="growl" | 
				
			|||
                                         ajax="false"/> | 
				
			|||
 | 
				
			|||
                        <p:commandButton action="Pais.xhtml"  | 
				
			|||
                                         actionListener="#{demoBeanPais.editarPais()}" | 
				
			|||
                                         icon="pi pi-fw pi-pencil" | 
				
			|||
                                         style="padding: 2px 8px; font-size: 13px; font-weight: bold; color: #3366FF; background-color: #fff; border: 2px solid #3366FF; border-radius: 8px; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); transition: transform 0.3s ease ; margin-right: 6px;" | 
				
			|||
 | 
				
			|||
                                         rendered="#{!demoBeanPais.nuevo}" | 
				
			|||
                                         value="Editar" | 
				
			|||
                                         update="growl" | 
				
			|||
                                         ajax="false"/> | 
				
			|||
 | 
				
			|||
                        <p:commandButton action="Pais.xhtml" icon="pi pi-fw pi-times" | 
				
			|||
                                         value="Cancelar" | 
				
			|||
                                         style=" padding: 2px 8px; font-size: 13px; font-weight: bold; color: #990000; background-color: #fff; border: 2px solid #FF0000; border-radius: 8px; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); transition: transform 0.3s ease; margin-right: 6px;" | 
				
			|||
 | 
				
			|||
                                         immediate="true" | 
				
			|||
                                         ajax="false"/> | 
				
			|||
                    </h:form> | 
				
			|||
                </f:view> | 
				
			|||
 | 
				
			|||
            </ui:define> | 
				
			|||
 | 
				
			|||
            <ui:define name="bottom"> | 
				
			|||
 | 
				
			|||
            </ui:define> | 
				
			|||
 | 
				
			|||
        </ui:composition> | 
				
			|||
 | 
				
			|||
    </body> | 
				
			|||
</html> | 
				
			|||
@ -0,0 +1,62 @@ | 
				
			|||
<?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" | 
				
			|||
      xmlns:p="http://primefaces.org/ui"> | 
				
			|||
 | 
				
			|||
    <body> | 
				
			|||
 | 
				
			|||
        <ui:composition template="./template/Principal.xhtml"> | 
				
			|||
 | 
				
			|||
            <ui:define name="top"> | 
				
			|||
                SISTEMA DE INVENTARIO | 
				
			|||
            </ui:define> | 
				
			|||
 | 
				
			|||
            <ui:define name="left"> | 
				
			|||
 | 
				
			|||
            </ui:define> | 
				
			|||
 | 
				
			|||
            <ui:define name="right"> | 
				
			|||
 | 
				
			|||
            </ui:define> | 
				
			|||
 | 
				
			|||
            <ui:define name="content"> | 
				
			|||
                <f:view> | 
				
			|||
 | 
				
			|||
 | 
				
			|||
                    <h:form> | 
				
			|||
                        <h1><h:outputText value="Eliminar"/></h1> | 
				
			|||
                        <p:panelGrid columns="2"> | 
				
			|||
                            <h:outputText value="Id:"/> | 
				
			|||
                            <h:outputText value="#{demoBeanPais.filteredCustomers3.id}" title="Id"/> | 
				
			|||
                            <h:outputText value="Nombre:"/> | 
				
			|||
                            <h:outputText value="#{demoBeanPais.filteredCustomers3.nombre}" title="Nombre"/> | 
				
			|||
                            <h:outputText value="Status:"/> | 
				
			|||
                            <h:outputText value="#{demoBeanPais.filteredCustomers3.status}" title="Status"/> | 
				
			|||
                             | 
				
			|||
                            <p:commandButton action="Pais.xhtml" icon="pi pi-fw pi-trash" | 
				
			|||
                                             actionListener="#{demoBeanPais.eliminaPais()}"  | 
				
			|||
                                             style=" padding: 2px 8px; font-size: 13px; font-weight: bold; color: #990000; background-color: #fff; border: 2px solid #FF0000; border-radius: 8px; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); transition: transform 0.3s ease; margin-right: 6px;" | 
				
			|||
                                             value="Eliminar"  | 
				
			|||
                                             ajax="false"/> | 
				
			|||
                            <p:commandButton action="Pais.xhtml" icon="pi pi-fw pi-times" | 
				
			|||
                                             style=" padding: 2px 8px; font-size: 13px; font-weight: bold; color: #990000; background-color: #fff; border: 2px solid #FF0000; border-radius: 8px; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); transition: transform 0.3s ease; margin-right: 6px;" | 
				
			|||
                                             value="Cancelar"   | 
				
			|||
                                             immediate="true" | 
				
			|||
                                             ajax="false"/> | 
				
			|||
                        </p:panelGrid> | 
				
			|||
                    </h:form> | 
				
			|||
                </f:view> | 
				
			|||
 | 
				
			|||
            </ui:define> | 
				
			|||
 | 
				
			|||
            <ui:define name="bottom"> | 
				
			|||
 | 
				
			|||
            </ui:define> | 
				
			|||
 | 
				
			|||
        </ui:composition> | 
				
			|||
 | 
				
			|||
    </body> | 
				
			|||
</html> | 
				
			|||
					Loading…
					
					
				
		Reference in new issue