Browse Source
			
			
			
			
				
		Creacion de RolesEndPoint todos los metods GET (Agregar, editar, eliminar, buscar)master
				 43 changed files with 1240 additions and 2 deletions
			
			
		| @ -0,0 +1,180 @@ | |||
| /* | |||
|  * 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 mx.edu.tsj.chapala.sistemas.inventario.modelo.bl; | |||
| 
 | |||
| import java.util.List; | |||
| import javax.ejb.Stateless; | |||
| import mx.edu.tsj.chapala.sistemas.inventario.modelo.dao.TokenDAO; | |||
| import mx.edu.tsj.chapala.sistemas.inventario.modelo1.Token; | |||
| import mx.edu.tsj.chapala.sistemas.inventario.msg.Mensaje; | |||
| /** | |||
|  * | |||
|  * @author Ivan Alejandro PC | |||
|  */ | |||
| @Stateless | |||
| public class TokenBL implements TokenBLLocal { | |||
| 
 | |||
|     @Override | |||
|     public Mensaje agregar(Token token) { | |||
|         System.out.println("Llegaste al metodo de agregar!!"); | |||
|         TokenDAO tokenDAO = new TokenDAO(); | |||
|          | |||
|          | |||
|         if(token== null){ | |||
|               return Mensaje.CAMPOS_INCOMPLETOS;  | |||
|         } | |||
|         | |||
|         Token existeToken = tokenDAO.buscarPorId(token); | |||
|         //TO DO: agregar la logica
 | |||
|          | |||
|         //Test de validaciones 
 | |||
|         if(token.getToken().isEmpty() | token.getServicio().isEmpty()){ | |||
|            return Mensaje.CAMPOS_INCOMPLETOS;  | |||
|         } | |||
|          | |||
|         if(token.getToken().length()>50 | token.getServicio().length()>255 ){ | |||
|             return Mensaje.DATOS_INCORRECTOS;  | |||
|         } | |||
|          | |||
|          if (existeToken != null) { | |||
|             return Mensaje.ELEMENTO_DUPLICADO; | |||
|     }else{ | |||
|         tokenDAO.agregar(token); | |||
|         return Mensaje.SIN_ERROR; | |||
|          | |||
|          } | |||
|     } | |||
|      | |||
| 
 | |||
|      | |||
|      @Override | |||
|     public Mensaje buscarId(Token token) { | |||
|         TokenDAO tokenDAO = new TokenDAO(); | |||
|         Token existeToken = tokenDAO.buscarPorId(token); | |||
|          | |||
|         if(token== null){ | |||
|               return Mensaje.CAMPOS_INCOMPLETOS;  | |||
|         } | |||
|          | |||
|          if (existeToken == null) { | |||
|             return Mensaje.ELEMENTO_NO_ENCONTRADO; | |||
|     }else{ | |||
|          tokenDAO.buscarPorId(token); | |||
|         return Mensaje.SIN_ERROR; | |||
|          | |||
|          } | |||
|     } | |||
|      | |||
|     @Override | |||
|     public Token buscarIdLi(Token token) { | |||
|          | |||
|         TokenDAO a = new TokenDAO(); | |||
|         //Aqui le movi
 | |||
|         return a.buscarPorId(token); | |||
|          | |||
|     } | |||
|      | |||
|     | |||
| 
 | |||
|     @Override | |||
|     public Mensaje eliminar(Token token) { | |||
|           TokenDAO a = new TokenDAO(); | |||
|         Token existe = a.buscarPorId(token); | |||
|          | |||
|         if(existe==null){ | |||
|              return Mensaje.ELEMENTO_NO_ENCONTRADO; | |||
|          | |||
|         }else if(token==null){ | |||
|             return Mensaje.ELEMENTO_NO_ENCONTRADO; | |||
|         }else{ | |||
|             a.eliminar(token); | |||
|             return Mensaje.SIN_ERROR;  | |||
|        | |||
|         } | |||
|          | |||
| 
 | |||
|          | |||
|     } | |||
|      | |||
|      | |||
|     @Override | |||
|     public List<Token> buscarTodos() { | |||
|     TokenDAO rolDAO = new TokenDAO(); | |||
|     return rolDAO.buscarTodos(); | |||
| } | |||
|        @Override | |||
|     public Mensaje buscarRol(Token token) { | |||
|     TokenDAO tokenDAO = new TokenDAO(); | |||
|     Token rE = tokenDAO.buscarPorTokenName(token); | |||
| 
 | |||
|     if (rE == null) { | |||
|         return Mensaje.ELEMENTO_NO_ENCONTRADO; | |||
|     } else { | |||
|         return Mensaje.SIN_ERROR; | |||
|     } | |||
| 
 | |||
|     } | |||
|      | |||
|     //Test de Token
 | |||
|     @Override | |||
| public Mensaje buscarToken(Token token) { | |||
|     TokenDAO tokenDAO = new TokenDAO(); | |||
|     Token rE = tokenDAO.buscarPorTokenName1(token); | |||
| 
 | |||
|     if (rE == null) { | |||
|         return Mensaje.ELEMENTO_NO_ENCONTRADO; | |||
|     } else { | |||
|         return Mensaje.SIN_ERROR; | |||
|     } | |||
| } | |||
| 
 | |||
| 
 | |||
|     @Override | |||
|     public Mensaje editar(Token token) { | |||
|          System.out.println("Llegaste al metodo de editar"); | |||
|           TokenDAO a = new TokenDAO(); | |||
|         //Rol existeRol = a.buscarPorId(rol);
 | |||
|         if(token== null){ | |||
|               return Mensaje.CAMPOS_INCOMPLETOS;  | |||
|         } | |||
|          //Test de validaciones 
 | |||
|         if(token.getToken().isEmpty() | token.getServicio().isEmpty()){ | |||
|            return Mensaje.CAMPOS_INCOMPLETOS;  | |||
|         } | |||
|          | |||
|         if(token.getToken().length()>50 | token.getServicio().length()>255 ){ | |||
|             return Mensaje.DATOS_INCORRECTOS;  | |||
|         } | |||
|          | |||
|         if(token.getId()==null){ | |||
|             return Mensaje.ELEMENTO_NO_ENCONTRADO; | |||
|         }else{ | |||
|         a.editar(token); | |||
|         return Mensaje.SIN_ERROR; | |||
|          | |||
|          } | |||
|       | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public void editar(String string) { | |||
|         throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
 | |||
|     } | |||
| 
 | |||
|      | |||
|      | |||
|      | |||
| 
 | |||
|      | |||
| 
 | |||
|      | |||
|      | |||
|      | |||
|      | |||
|      | |||
|      | |||
| } | |||
| 
 | |||
| 
 | |||
| @ -0,0 +1,45 @@ | |||
| /* | |||
|  * 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 mx.edu.tsj.chapala.sistemas.inventario.modelo.bl; | |||
| 
 | |||
| import java.util.List; | |||
| import javax.ejb.Local; | |||
| import mx.edu.tsj.chapala.sistemas.inventario.modelo1.Token; | |||
| import mx.edu.tsj.chapala.sistemas.inventario.msg.Mensaje; | |||
| /** | |||
|  * | |||
|  * @author Ivan Alejandro PC | |||
|  */ | |||
| @Local | |||
| public interface TokenBLLocal { | |||
| 
 | |||
|     Mensaje agregar(Token token); | |||
| 
 | |||
|  Mensaje buscarRol(Token token); | |||
| 
 | |||
|         Mensaje buscarId(Token token); | |||
|      | |||
|     Token buscarIdLi(Token token); | |||
| 
 | |||
|     Mensaje eliminar(Token token); | |||
| 
 | |||
|     Mensaje editar(Token token); | |||
|      | |||
|     public List<Token> buscarTodos(); | |||
|      | |||
|     public Mensaje buscarToken(Token token); | |||
| 
 | |||
|     public void editar(String editar); | |||
| 
 | |||
|    // public void editar(String editar);
 | |||
|      | |||
|      | |||
| 
 | |||
|      | |||
| 
 | |||
| 
 | |||
|    | |||
|      | |||
| } | |||
| @ -0,0 +1,111 @@ | |||
| /* | |||
|  * 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 mx.edu.tsj.chapala.sistemas.inventario.modelo.dao; | |||
| 
 | |||
| import java.util.List; | |||
| import javax.persistence.EntityManager; | |||
| import javax.persistence.EntityManagerFactory; | |||
| import javax.persistence.Persistence; | |||
| import javax.persistence.Query; | |||
| import mx.edu.tsj.chapala.sistemas.inventario.modelo1.Token; | |||
| 
 | |||
| /** | |||
|  * | |||
|  * @author Ivan Alejandro PC | |||
|  */ | |||
| public class TokenDAO { | |||
|      | |||
|     private EntityManager em; //Manejadro de identidades
 | |||
| 
 | |||
|     public TokenDAO() { | |||
|         EntityManagerFactory emf = Persistence.createEntityManagerFactory("Inventario-ejbPU"); | |||
|         em = emf.createEntityManager(); | |||
|     } | |||
|     /*   | |||
|     Este es un prueba de actualizar | |||
|     */ | |||
|      | |||
|     public void agregar(Token a){ | |||
|         em.getTransaction().begin();//Empezar 
 | |||
|        em.persist(a);//Almacenar en la BD
 | |||
|        em.getTransaction().commit();// terminar 
 | |||
|         | |||
|     } | |||
|      | |||
|     public void editar(Token a){ | |||
|          | |||
|         em.getTransaction().begin();//Empezar 
 | |||
|        em.merge(a);//Actualizar en la BD
 | |||
|        em.getTransaction().commit();// terminar 
 | |||
|        | |||
| 
 | |||
| 
 | |||
|         | |||
|     } | |||
|     public void eliminar(Token a){ | |||
|         em.getTransaction().begin();//Empezar 
 | |||
|        em.remove(em.merge(a));//Eliminar en la BD
 | |||
|        em.getTransaction().commit();// terminar 
 | |||
|         | |||
|     } | |||
|      | |||
| 
 | |||
|        public Token buscarPorTokenName(Token a){ | |||
|     /*if(a.getStatus()==0){ | |||
|         return null; | |||
|     }*/ | |||
|     if (a.getToken()== null) { | |||
|         return null; | |||
|     } | |||
|     Query q = em.createNamedQuery("Token.findByServicio"); | |||
|     q.setParameter("servicio", a.getToken()); | |||
|     List<Token> resultList = q.getResultList(); | |||
|     if(resultList.isEmpty()){ | |||
|         return null; | |||
|     } else { | |||
|         return resultList.get(0); | |||
|     } | |||
| } | |||
|        public Token buscarPorTokenName1(Token a) { | |||
|     if (a.getToken() == null) { | |||
|         return null; | |||
|     } | |||
|     Query q = em.createNamedQuery("Token.findByToken"); | |||
|     q.setParameter("token", a.getToken()); | |||
|     List<Token> resultList = q.getResultList(); | |||
|     if (resultList.isEmpty()) { | |||
|         return null; | |||
|     } else { | |||
|         return resultList.get(0); | |||
|     } | |||
| } | |||
|      | |||
| 
 | |||
|      | |||
|      | |||
|     public Token buscarPorId(Token a){ | |||
|           if (a == null || a.getId()== null) { | |||
|         return null; | |||
|     } | |||
|     Query q = em.createNamedQuery("Token.findById"); | |||
|     q.setParameter("id", a.getId()); | |||
|     if(q.getResultList().isEmpty()){ | |||
|         return null; | |||
|     } else { | |||
|         return (Token) q.getResultList().get(0); | |||
|     } | |||
| } | |||
|      | |||
|     | |||
|         | |||
|         public List<Token> buscarTodos(){ | |||
|     Query q = em.createNamedQuery("Token.findAll"); | |||
|     return q.getResultList(); | |||
| }        | |||
|                | |||
| 
 | |||
|      | |||
|      | |||
| } | |||
| @ -0,0 +1,132 @@ | |||
| /* | |||
|  * 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 mx.edu.tsj.chapala.sistemas.inventario.modelo1; | |||
| 
 | |||
| import java.io.Serializable; | |||
| import java.util.Date; | |||
| import javax.persistence.Basic; | |||
| import javax.persistence.Column; | |||
| import javax.persistence.Entity; | |||
| import javax.persistence.GeneratedValue; | |||
| import javax.persistence.GenerationType; | |||
| import javax.persistence.Id; | |||
| import javax.persistence.NamedQueries; | |||
| import javax.persistence.NamedQuery; | |||
| import javax.persistence.Table; | |||
| import javax.persistence.Temporal; | |||
| import javax.persistence.TemporalType; | |||
| import javax.validation.constraints.NotNull; | |||
| import javax.validation.constraints.Size; | |||
| import javax.xml.bind.annotation.XmlRootElement; | |||
| 
 | |||
| /** | |||
|  * | |||
|  * @author Ivan Alejandro PC | |||
|  */ | |||
| @Entity | |||
| @Table(name = "token") | |||
| @XmlRootElement | |||
| @NamedQueries({ | |||
|     @NamedQuery(name = "Token.findAll", query = "SELECT t FROM Token t"), | |||
|     @NamedQuery(name = "Token.findById", query = "SELECT t FROM Token t WHERE t.id = :id"), | |||
|     @NamedQuery(name = "Token.findByServicio", query = "SELECT t FROM Token t WHERE t.servicio = :servicio"), | |||
|     @NamedQuery(name = "Token.findByToken", query = "SELECT t FROM Token t WHERE t.token = :token"), | |||
|     @NamedQuery(name = "Token.findByFecha", query = "SELECT t FROM Token t WHERE t.fecha = :fecha")}) | |||
| public class Token implements Serializable { | |||
| 
 | |||
|     private static final long serialVersionUID = 1L; | |||
|     @Id | |||
|     @GeneratedValue(strategy = GenerationType.IDENTITY) | |||
|     @Basic(optional = false) | |||
|     @Column(name = "id") | |||
|     private Integer id; | |||
|     @Basic(optional = false) | |||
|     @NotNull | |||
|     @Size(min = 1, max = 255) | |||
|     @Column(name = "servicio") | |||
|     private String servicio; | |||
|     @Basic(optional = false) | |||
|     @NotNull | |||
|     @Size(min = 1, max = 50) | |||
|     @Column(name = "token") | |||
|     private String token; | |||
|     @Basic(optional = false) | |||
|     @NotNull | |||
|     @Column(name = "fecha") | |||
|     @Temporal(TemporalType.DATE) | |||
|     private Date fecha; | |||
| 
 | |||
|     public Token() { | |||
|     } | |||
| 
 | |||
|     public Token(Integer id) { | |||
|         this.id = id; | |||
|     } | |||
| 
 | |||
|     public Token(Integer id, String servicio, String token, Date fecha) { | |||
|         this.id = id; | |||
|         this.servicio = servicio; | |||
|         this.token = token; | |||
|         this.fecha = fecha; | |||
|     } | |||
| 
 | |||
|     public Integer getId() { | |||
|         return id; | |||
|     } | |||
| 
 | |||
|     public void setId(Integer id) { | |||
|         this.id = id; | |||
|     } | |||
| 
 | |||
|     public String getServicio() { | |||
|         return servicio; | |||
|     } | |||
| 
 | |||
|     public void setServicio(String servicio) { | |||
|         this.servicio = servicio; | |||
|     } | |||
| 
 | |||
|     public String getToken() { | |||
|         return token; | |||
|     } | |||
| 
 | |||
|     public void setToken(String token) { | |||
|         this.token = token; | |||
|     } | |||
| 
 | |||
|     public Date getFecha() { | |||
|         return fecha; | |||
|     } | |||
| 
 | |||
|     public void setFecha(Date fecha) { | |||
|         this.fecha = fecha; | |||
|     } | |||
| 
 | |||
|     @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 Token)) { | |||
|             return false; | |||
|         } | |||
|         Token other = (Token) 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 "mx.edu.tsj.chapala.sistemas.inventario.modelo1.Token[ id=" + id + " ]"; | |||
|     } | |||
|      | |||
| } | |||
| @ -0,0 +1,162 @@ | |||
| package mx.edu.itsj.servicios; | |||
| 
 | |||
| import java.io.IOException; | |||
| import java.io.PrintWriter; | |||
| import javax.ejb.EJB; | |||
| import javax.servlet.ServletException; | |||
| import javax.servlet.annotation.WebServlet; | |||
| import javax.servlet.http.HttpServlet; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import mx.edu.tsj.chapala.sistemas.inventario.modelo.bl.RolBLLocal; | |||
| import mx.edu.tsj.chapala.sistemas.inventario.modelo.bl.TokenBLLocal; | |||
| import mx.edu.tsj.chapala.sistemas.inventario.modelo1.Rol; | |||
| import mx.edu.tsj.chapala.sistemas.inventario.modelo1.Token; | |||
| import mx.edu.tsj.chapala.sistemas.inventario.msg.Mensaje; | |||
| 
 | |||
| @WebServlet(name = "RolesEndpoint", urlPatterns = {"/RolesEndpoint"}) | |||
| public class RolesEndpoint extends HttpServlet { | |||
| 
 | |||
|     @EJB | |||
|     private TokenBLLocal tokenBL; | |||
| 
 | |||
|     @EJB | |||
|     private RolBLLocal rolBL; | |||
| 
 | |||
|     protected void processRequest(HttpServletRequest request, HttpServletResponse response) | |||
|             throws ServletException, IOException { | |||
|         response.setContentType("text/html;charset=UTF-8"); | |||
|         try (PrintWriter out = response.getWriter()) { | |||
|             String rolOpcion = request.getParameter("rolOpcion"); | |||
|             String valor = request.getParameter("valor"); | |||
|             String tokenParam = request.getParameter("token"); | |||
|             String buscar = request.getParameter("buscar"); | |||
| 
 | |||
|             if (areParamsInvalid(rolOpcion, tokenParam)) { | |||
|                 out.print("Parametros invalidos"); | |||
|                 return; | |||
|             } | |||
| 
 | |||
|             Token token = new Token(); | |||
|             token.setToken(tokenParam); | |||
| 
 | |||
|             Mensaje tokenValidationResult = tokenBL.buscarToken(token); | |||
|             if (tokenValidationResult == Mensaje.ELEMENTO_NO_ENCONTRADO) { | |||
|                 out.print("Token invalido"); | |||
|                 return; | |||
|             } | |||
| 
 | |||
|             switch (rolOpcion) { | |||
|                 case "0": | |||
|                     mostrarTodos(out); | |||
|                     break; | |||
|                 case "1": | |||
|                     if (isParamInvalid(valor)) { | |||
|                         out.print("Parametros invalidos Agregar"); | |||
|                     } else { | |||
|                         agregarRol(valor, out); | |||
|                     } | |||
|                     break; | |||
|                 case "2": | |||
|                     if (isParamInvalid(buscar) || isParamInvalid(valor)) { | |||
|                         out.print("Parametros invalidos Editar"); | |||
|                     } else { | |||
|                         editarRol(buscar, valor, out); | |||
|                     } | |||
|                     break; | |||
|                 case "3": | |||
|                     if (isParamInvalid(buscar)) { | |||
|                         out.print("Parametros invalidos Eliminar"); | |||
|                     } else { | |||
|                         eliminarRol(buscar, out); | |||
|                     } | |||
|                     break; | |||
|                 case "4": | |||
|                     if (isParamInvalid(buscar)) { | |||
|                         out.print("Parametros invalidos Buscar"); | |||
|                     } else { | |||
|                         buscarRol(buscar, out); | |||
|                     } | |||
|                     break; | |||
|                 default: | |||
|                     out.print("Opcion invalida"); | |||
|                     break; | |||
|             } | |||
|         } | |||
|     } | |||
| 
 | |||
|     private boolean areParamsInvalid(String rolOpcion, String tokenParam) { | |||
|         return rolOpcion == null || rolOpcion.trim().isEmpty() || | |||
|                tokenParam == null || tokenParam.trim().isEmpty(); | |||
|     } | |||
| 
 | |||
|     private boolean isParamInvalid(String param) { | |||
|         return param == null || param.trim().isEmpty(); | |||
|     } | |||
| 
 | |||
|     private void mostrarTodos(PrintWriter out) { | |||
|         out.print("<table border='1'>"); | |||
|         out.print("<tr><th colspan='1'>Roles de Usuario</th></tr>"); | |||
|         out.print("<tr><th>Rol Usuario</th></tr>"); | |||
| 
 | |||
|         for (Rol r : rolBL.buscarTodos()) { | |||
|             out.print("<tr><td>" + r.getRolUsuario() + "</td></tr>"); | |||
|         } | |||
| 
 | |||
|         out.print("</table>"); | |||
|     } | |||
| 
 | |||
|     private void agregarRol(String valor, PrintWriter out) { | |||
|         Rol a = new Rol(); | |||
|         a.setRolUsuario(valor); | |||
|         rolBL.agregar(a); | |||
|         out.print("Rol agregado"); | |||
|     } | |||
| 
 | |||
|     private void editarRol(String buscar, String valor, PrintWriter out) { | |||
|         Rol a = rolBL.buscarIdLi(new Rol(Integer.parseInt(buscar.trim()))); | |||
|         if (a == null) { | |||
|             out.print("Rol no encontrado"); | |||
|             return; | |||
|         } | |||
|         a.setRolUsuario(valor); | |||
|         rolBL.editar(a); | |||
|         out.print("Rol editado"); | |||
|     } | |||
| 
 | |||
|     private void eliminarRol(String buscar, PrintWriter out) { | |||
|         Rol a = rolBL.buscarIdLi(new Rol(Integer.parseInt(buscar.trim()))); | |||
|         if (a == null) { | |||
|             out.print("Rol no encontrado"); | |||
|             return; | |||
|         } | |||
|         rolBL.eliminar(a); | |||
|         out.print("Rol eliminado"); | |||
|     } | |||
| 
 | |||
|     private void buscarRol(String buscar, PrintWriter out) { | |||
|         Rol a = rolBL.buscarIdLi(new Rol(Integer.parseInt(buscar.trim()))); | |||
|         if (a == null) { | |||
|             out.print("Rol no encontrado"); | |||
|             return; | |||
|         } | |||
|         out.print("Rol encontrado: " + a.getRolUsuario()); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     protected void doGet(HttpServletRequest request, HttpServletResponse response) | |||
|             throws ServletException, IOException { | |||
|         processRequest(request, response); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     protected void doPost(HttpServletRequest request, HttpServletResponse response) | |||
|             throws ServletException, IOException { | |||
|         processRequest(request, response); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public String getServletInfo() { | |||
|         return "Roles Endpoint Servlet"; | |||
|     } | |||
| } | |||
| @ -0,0 +1,241 @@ | |||
| /* | |||
|  * 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 mx.edu.tsj.chapala.sistemas.inventario.vista; | |||
| 
 | |||
| import javax.inject.Named; | |||
| import javax.enterprise.context.SessionScoped; | |||
| import java.io.Serializable; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import javax.ejb.EJB; | |||
| import javax.faces.application.FacesMessage; | |||
| import javax.faces.context.FacesContext; | |||
| import mx.edu.tsj.chapala.sistemas.inventario.modelo1.Token; | |||
| import mx.edu.tsj.chapala.sistemas.inventario.msg.Mensaje; | |||
| import mx.edu.tsj.chapala.sistemas.inventario.modelo.bl.TokenBLLocal; | |||
| 
 | |||
| /** | |||
|  * | |||
|  * @author Ivan Alejandro PC | |||
|  */ | |||
| @Named(value = "demoBeanToken") | |||
| @SessionScoped | |||
| public class DemoBeanToken implements Serializable { | |||
|     | |||
| 
 | |||
|     @EJB | |||
|     private TokenBLLocal tokenBL; | |||
|      | |||
|     private Token token = new Token(); | |||
|     private String titulo; | |||
|     private boolean nuevo; | |||
|      | |||
|      | |||
|      | |||
| 
 | |||
|     /** | |||
|      * Creates a new instance of DemoBean | |||
|      */ | |||
|     public DemoBeanToken() { | |||
|     } | |||
|      | |||
|     //Aqui empieza lo de la clase pasada
 | |||
|         //Metodo para eliminar
 | |||
|      | |||
|     public void eliminarToken(){ | |||
|         tokenBL.eliminar(token); | |||
|     } | |||
|      | |||
|     public void prepararEliminar(Token token){ | |||
|         this.token=token;   | |||
|     } | |||
|      | |||
|     //Metodo de editar
 | |||
| 
 | |||
|     public String getTitulo() { | |||
|         return titulo; | |||
|     } | |||
| 
 | |||
|     public boolean isNuevo() { | |||
|         return nuevo; | |||
|     } | |||
|      | |||
|      | |||
|     public void editarRoles(){ | |||
|         tokenBL.editar(token); | |||
|     } | |||
|      | |||
|      | |||
|     public void prepararEditar(Token token){ | |||
|         nuevo = false; | |||
|         titulo="Editando Token"; | |||
|         this.token=token; | |||
|     } | |||
|      | |||
|      public void prepararNuevo(){ | |||
|          nuevo =true; | |||
|         titulo="Agregando Token"; | |||
|         token = new Token(); | |||
|     } | |||
|       | |||
|      | |||
|       public String agregarToken(){ | |||
|           | |||
|     tokenBL.agregar(token); | |||
|      | |||
|      token = new Token(); | |||
|       | |||
|     return "tokenLista.xhtml"; | |||
|     } | |||
|        | |||
|       //Aqui esta para crear token
 | |||
|        | |||
|        private String tokenInput; | |||
| 
 | |||
|     public String getTokenInput() { | |||
|         return tokenInput; | |||
|     } | |||
| 
 | |||
|     public void setTokenInput(String tokenInput) { | |||
|         this.tokenInput = tokenInput; | |||
|     } | |||
| 
 | |||
|     public void crearToken() { | |||
|     String cad = "rdfgfiodgionergnio345nio3in"; | |||
|     StringBuilder tokenBuilder = new StringBuilder(); | |||
|     for (int x = 0; x < 48; x++) { | |||
|         tokenBuilder.append(cad.charAt((int) (Math.random() * (cad.length() - 1)))); | |||
|     } | |||
|     | |||
|     String tokenValue = tokenBuilder.toString(); | |||
|      | |||
|     token.setToken(tokenValue); | |||
|      | |||
|        // Generar la fecha de registro automáticamente
 | |||
|        // Obtener la fecha actual
 | |||
|     Date fechaActual = new Date(); | |||
|      | |||
|     // Convertir la fecha actual a String y asignarla al campo fecha
 | |||
|     token.setFecha(fechaActual); | |||
|      | |||
|     System.out.println("Token generado: " + token.getToken()); | |||
|     | |||
|     FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Token generado", "El token ha sido generado correctamente.")); | |||
| } | |||
| 
 | |||
|       //-------------------------
 | |||
|        | |||
|           public Token getToken() { | |||
|         return token; | |||
|     } | |||
| 
 | |||
|     public void setToken(Token token) { | |||
|         this.token = token; | |||
|     } | |||
|      | |||
|       public List<Token> getListToken(){ | |||
|          return tokenBL.buscarTodos(); | |||
|      } | |||
|       | |||
|      | |||
|    /* public String metodo(){ | |||
|         Token a = new Token(); | |||
|         //Para que te marque como id duplicaod tienes que asignarlo
 | |||
|         //a.setId(1);
 | |||
|         a.setToken("Administrador"); | |||
|          | |||
|          | |||
|         Mensaje m = rolBL.agregar(a); | |||
|         System.out.println(m); | |||
|         if(m.compareTo(Mensaje.SIN_ERROR)==0){ | |||
|             System.out.println("SE AGREGRO"); | |||
|         }else{ | |||
|             System.out.println("NO SE PUDO"); | |||
|         } | |||
|         return "index.xhtml"; | |||
|     }*/ | |||
|      | |||
|     /*public String buscar(){ | |||
|         Rol a = new Rol(); | |||
|         a.setId(31); | |||
|         Mensaje m = rolBL.buscarId(a); | |||
|         System.out.println(m); | |||
|         if(m.compareTo(Mensaje.SIN_ERROR)==0){ | |||
|             System.out.println("Encontre el Rol: " + a.getId()); | |||
|             System.out.println(rolBL.buscarId(a)); | |||
|         }else{ | |||
|             System.out.println("NO SE ENCONTRO"); | |||
|         } | |||
|         //System.out.println("Encontre el Autor: ");
 | |||
|         //System.out.println(autorBL.buscarId(a));
 | |||
|         return "index.xhtml"; | |||
|     } | |||
|          public String buscarPorNombre(){ | |||
|     Rol a = new Rol(); | |||
|     a.setRolUsuario("Ivan Alejandro"); | |||
|     Mensaje m = rolBL.buscarRol(a); | |||
|     System.out.println(m); | |||
|     if(m.compareTo(Mensaje.SIN_ERROR)==0){ | |||
|         System.out.println("Encontre el Rol: " + a.getRolUsuario()); | |||
|     }else{ | |||
|         System.out.println("NO SE ENCONTRO"); | |||
|     } | |||
| 
 | |||
|     return "index.xhtml"; | |||
| } | |||
|     */ | |||
|  /*public String buscarALLRol() { | |||
|         //short status = 1;
 | |||
|     List<Rol> usuariosStatus1 = rolBL.buscarTodos(); | |||
|     if (!usuariosStatus1.isEmpty()) { | |||
|         System.out.println("Busqueda All: "); | |||
|         for (Rol rol : usuariosStatus1) { | |||
|             | |||
|             System.out.println("Encontre los roles de usuario: "+ "ID: " + rol.getId() +" Rol: " + rol.getRolUsuario() ); | |||
|         } | |||
|          | |||
|     } else { | |||
|         System.out.println("No se encontraron roles de usuarios"); | |||
|     } | |||
|      return "index.xhtml"; | |||
|  }*/ | |||
| 
 | |||
|      | |||
|     /*public String eliminar(){ | |||
|         Rol a = rolBL.buscarIdLi(new Rol(33)); | |||
|         System.out.println("Autor eliminado: "); | |||
|         Mensaje m = rolBL.eliminar(a); | |||
|         System.out.println(m); | |||
|         if(m.compareTo(Mensaje.SIN_ERROR)==0){ | |||
|             System.out.println("SE AGREGRO"); | |||
|         }else{ | |||
|             System.out.println("NO SE PUDO"); | |||
|         } | |||
|         //System.out.println(autorBL.eliminar(a));
 | |||
|         return "index.xhtml"; | |||
|     } | |||
|     */ | |||
|     /*public String editar() { | |||
|         try{ | |||
|     Rol a = rolBL.buscarIdLi(new Rol(35)); | |||
|     a.setRolUsuario("Trabajador"); | |||
| 
 | |||
|      Mensaje m = rolBL.editar(a); | |||
|         System.out.println(m); | |||
|         if(m.compareTo(Mensaje.SIN_ERROR)==0){ | |||
|             System.out.println("SE AGREGRO"); | |||
|         }else{ | |||
|             System.out.println("NO SE PUDO"); | |||
|         } | |||
|             }catch(Exception e){ | |||
|             System.out.println("Ha ocurrido un error: " + Mensaje.ELEMENTO_NO_ENCONTRADO); | |||
|         } | |||
|     //autorBL.editar(a);
 | |||
|     return "index.xhtml"; | |||
| }*/ | |||
|      | |||
| } | |||
| @ -0,0 +1,71 @@ | |||
| <?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/productosP.xhtml"> | |||
|             <ui:define name="top"> | |||
|                 <center></center> | |||
|             </ui:define> | |||
|             <ui:define name="left"> | |||
|                 <div class="card" style="text-align: left;"> | |||
|                     <h:form> | |||
|                         <p:growl id="messages" showDetail="true"/> | |||
|                         <p:tieredMenu style="width:170px"> | |||
|                             <p:submenu label="Usuarios"> | |||
|                                 <p:menuitem value="Usuario" outcome="marcaLista3.xhtml" ajax="false"/>   | |||
|                                 <p:menuitem value="Rol" outcome="rolLista.xhtml" ajax="false"/>   | |||
|                             </p:submenu> | |||
|                             <p:submenu label="Proveedores"> | |||
|                                 <p:menuitem value="Proveedor" outcome="vistaProveedores.xhtml" ajax="false"/> | |||
|                                 <p:menuitem value="Almacen" outcome="ubicacionLista.xhtml" ajax="false"/>  | |||
|                             </p:submenu> | |||
|                             <p:submenu label="Productos"> | |||
|                                 <p:menuitem value="Producto" outcome="productosLista.xhtml" ajax="false"/>  | |||
|                                 <p:menuitem value="Categoria" outcome="categoriaLista.xhtml" ajax="false"/>   | |||
|                                 <p:menuitem value="Talla" outcome="tallaLista.xhtml" ajax="false"/> | |||
|                                 <p:menuitem value="Color" outcome="colorLista.xhtml" ajax="false"/>  | |||
|                                 <p:menuitem value="Marca" outcome="marcaLista.xhtml" ajax="false"/> | |||
|                                 <p:menuitem value="Genero" outcome="vistaGenero.xhtml" ajax="false"/>   | |||
|                             </p:submenu> | |||
|                             <p:submenu label="Sesión"> | |||
|                                 <p:divider/> | |||
|                                 <p:menuitem value="Token" outcome="tokenLista.xhtml" ajax="false"/>   | |||
|                                 <p:menuitem value="Cerrar sesión" icon="pi pi-fw pi-power-off" action="#{demoBeanLogin.logout()}"/>      | |||
|                             </p:submenu> | |||
|                         </p:tieredMenu> | |||
|                     </h:form> | |||
|                 </div>  | |||
|             </ui:define> | |||
|             <ui:define name="right"></ui:define> | |||
|             <ui:define name="content"> | |||
|                 <f:view> | |||
|                     <center> | |||
|                         <h:form style="background-color: white; margin: -10px;"> | |||
|                             <h1><h:outputText style="color: black;" value="#{demoBeanToken.titulo}"/></h1> | |||
|                             <p:growl id="growl" showDetail="true" /> | |||
|                             <div style="margin-top: 50px"> | |||
|                                 <p:outputLabel value="Servicio" for="servicio"  /> | |||
|                                 <p:inputText id="servicio" value="#{demoBeanToken.token.servicio}" style="margin: 20px" title="Servicio" required="true" requiredMessage="Se requiere campo Servicio"/> | |||
|                             </div> | |||
|                             <div style="margin-top: 50px"> | |||
|                                 <p:outputLabel value="Token" for="token" rendered="false" /> | |||
|                                 <p:inputText id="token" value="#{demoBeanToken.token.token}" style="margin: 20px" title="Token" required="true" requiredMessage="Se requiere campo Token" disabled="true" rendered="false"/> | |||
|                             </div> | |||
|                               <div> | |||
|                                 <p:outputLabel value="Fecha de Registro:" for="fechaRegistro" rendered="false"/> | |||
|                                 <p:inputText id="fechaRegistro" value="#{demoBeanToken.token.fecha}" style="margin-left: 20px; margin-right: 30px; margin-top: 20px; margin-bottom:20px" title="FechaRegistro" required="true" requiredMessage="Se requiere campo Fecha de Registro." disabled="true" rendered="false"/> | |||
|                             </div> | |||
|                             <p:commandButton action="#{demoBeanToken.agregarToken()}" actionListener="#{demoBeanToken.crearToken}" style="margin-left: 70px; margin-top: 30px" styleClass="rounded-button ui-button-success" value="Generar Token" update="growl" rendered="#{demoBeanToken.nuevo}" ajax="false" /> | |||
|                             <p:commandButton action="tokenLista.xhtml" style="margin-left: 10px" styleClass="rounded-button ui-button-danger" value="Cancelar" immediate="true" ajax="false"/> | |||
|                         </h:form> | |||
|                     </center> | |||
|                 </f:view> | |||
|             </ui:define> | |||
|         </ui:composition> | |||
|     </body> | |||
| </html> | |||
| @ -0,0 +1,103 @@ | |||
| <?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/productosP.xhtml"> | |||
| 
 | |||
|             <ui:define name="top"> | |||
|                 <center> | |||
|             </center> | |||
|                  | |||
|             </ui:define> | |||
| 
 | |||
|             <ui:define name="left"> | |||
|                  <div class="card" style="text-align: left;"> | |||
|     <h:form> | |||
|         <p:growl id="messages" showDetail="true"/> | |||
|         <p:tieredMenu  style="width:170px" > | |||
|              | |||
|             <p:submenu label="Usuarios" > | |||
|                  | |||
|                     <p:menuitem value="Usuario" outcome="marcaLista3.xhtml" ajax="false"/>   | |||
|                     <p:menuitem value="Rol"  outcome="rolLista.xhtml" ajax="false"/>   | |||
|                       | |||
|             </p:submenu> | |||
|                   | |||
|              <p:submenu label="Proveedores" > | |||
|                  | |||
|                     <p:menuitem value="Proveedor"  outcome="vistaProveedores.xhtml" ajax="false"/> | |||
|                     <p:menuitem value="Almacen"  outcome="ubicacionLista.xhtml" ajax="false"/>  | |||
|                       | |||
|             </p:submenu> | |||
|              | |||
|             <p:submenu label="Productos" > | |||
|                  | |||
|                     <p:menuitem value="Producto"  outcome="productosLista.xhtml" ajax="false"/>  | |||
|                     <p:menuitem value="Categoria" outcome="categoriaLista.xhtml" ajax="false"/>   | |||
|                     <p:menuitem value="Talla"  outcome="tallaLista.xhtml" ajax="false"/> | |||
|                     <p:menuitem value="Color" outcome="colorLista.xhtml" ajax="false"/>  | |||
|                     <p:menuitem value="Marca"  outcome="marcaLista.xhtml" ajax="false"/> | |||
|                     <p:menuitem value="Genero"  outcome="vistaGenero.xhtml" ajax="false"/>   | |||
|                        | |||
|             </p:submenu> | |||
|             <p:submenu label="Sesión" > | |||
|                    <p:divider/> | |||
|                             <p:menuitem value="Token"  outcome="tokenLista.xhtml" ajax="false"/>  | |||
|                             <p:menuitem value="Cerrar sesión" icon="pi pi-fw pi-power-off" action="#{demoBeanLogin.logout()}"/>      | |||
|             </p:submenu> | |||
| 
 | |||
|         </p:tieredMenu> | |||
| 
 | |||
|     | |||
|     </h:form> | |||
| </div>  | |||
|                  | |||
|             </ui:define> | |||
| 
 | |||
|             <ui:define name="right"> | |||
|                  | |||
|             </ui:define> | |||
| 
 | |||
|             <ui:define name="content"> | |||
|                 <f:view> | |||
| 
 | |||
|                     <center> | |||
|                     <h:form style="background-color: white; margin: -10px;"> | |||
|                         <h1><h:outputText style="color: black;" value="Eliminando Token"/></h1> | |||
|                          | |||
|                         <div style="margin-top: 50px"> | |||
|                             <h:outputText value="Id:"/> | |||
|                             <p:inputText value="#{demoBeanToken.token.id}" style="margin: 10px" title="Id" disabled="true"/> | |||
|                         </div> | |||
|                         <div> | |||
|                             <h:outputText value="Servicio:"/> | |||
|                             <p:inputText value="#{demoBeanToken.token.servicio}" style="margin-left: 10px; margin-right: 15px; margin-top: 10px; margin-bottom: 20px" disabled="true" title="Servicio" /> | |||
|                         </div> | |||
|                         <div> | |||
|                             <h:outputText value="Token:"/> | |||
|                             <p:inputText value="#{demoBeanToken.token.token}" style="margin-left: 10px; margin-right: 15px; margin-top: 10px; margin-bottom: 20px" disabled="true" title="Token" /> | |||
|                         </div> | |||
|                         <div> | |||
|                            <h:outputText value="FechaRegistro:" style="margin-left: -20px; "/> | |||
|                             <p:inputText value="#{demoBeanToken.token.fecha}" style="margin-left: 20px; margin-right: 90px; margin-bottom: 20px" disabled="true" title="Fecha de Registro"> | |||
|                                 <f:convertDateTime pattern="MM/dd/yyyy" /> | |||
|                             </p:inputText></div> | |||
|                         <p:commandButton action="tokenLista.xhtml" styleClass="rounded-button ui-button-success" style="margin-left: 30px; margin-top: 30px" actionListener="#{demoBeanToken.eliminarToken()}" value="Eliminar" ajax="false"/> | |||
|                           <p:commandButton action="tokenLista.xhtml" styleClass="rounded-button ui-button-danger" style="margin-left: 10px" value="Cancelar" immediate="true" ajax="false"/> | |||
|                      | |||
|                     </h:form> | |||
|                     </center> | |||
|                 </f:view> | |||
| 
 | |||
|             </ui:define> | |||
| 
 | |||
|         </ui:composition> | |||
| 
 | |||
|     </body> | |||
| </html> | |||
| @ -0,0 +1,135 @@ | |||
| <?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/productosP.xhtml"> | |||
| 
 | |||
|             <ui:define name="top"> | |||
|                 top | |||
|             </ui:define> | |||
| 
 | |||
|             <ui:define name="left"> | |||
|                 | |||
|              <div class="card" style="text-align: left;"> | |||
|     <h:form> | |||
|         <p:growl id="messages" showDetail="true"/> | |||
|         <p:tieredMenu  style="width:170px" > | |||
|              | |||
|             <p:submenu label="Usuarios" > | |||
|                  | |||
|                     <p:menuitem value="Usuario" outcome="marcaLista3.xhtml" ajax="false"/>   | |||
|                     <p:menuitem value="Rol"  outcome="rolLista.xhtml" ajax="false"/>   | |||
|                       | |||
|             </p:submenu> | |||
|                   | |||
|              <p:submenu label="Proveedores" > | |||
|                  | |||
|                     <p:menuitem value="Proveedor"  outcome="vistaProveedores.xhtml" ajax="false"/> | |||
|                     <p:menuitem value="Almacen"  outcome="ubicacionLista.xhtml" ajax="false"/>  | |||
|                       | |||
|             </p:submenu> | |||
|              | |||
|             <p:submenu label="Productos" > | |||
|                  | |||
|                     <p:menuitem value="Producto"  outcome="productosLista.xhtml" ajax="false"/>  | |||
|                     <p:menuitem value="Categoria" outcome="categoriaLista.xhtml" ajax="false"/>   | |||
|                     <p:menuitem value="Talla"  outcome="tallaLista.xhtml" ajax="false"/>  | |||
|                     <p:menuitem value="Color" outcome="colorLista.xhtml" ajax="false"/>  | |||
|                     <p:menuitem value="Marca"  outcome="marcaLista.xhtml" ajax="false"/> | |||
|                     <p:menuitem value="Genero"  outcome="vistaGenero.xhtml" ajax="false"/>   | |||
|                        | |||
|             </p:submenu> | |||
|             <p:submenu label="Sesión" > | |||
|                    <p:divider/> | |||
|                             <p:menuitem value="Token"  outcome="tokenLista.xhtml" ajax="false"/>   | |||
|                             <p:menuitem value="Cerrar sesión" icon="pi pi-fw pi-power-off" action="#{demoBeanLogin.logout()}"/>      | |||
|             </p:submenu> | |||
| 
 | |||
|         </p:tieredMenu> | |||
| 
 | |||
|     | |||
|     </h:form> | |||
| </div>  | |||
|              | |||
|               | |||
|             </ui:define> | |||
| 
 | |||
|             <ui:define name="right"> | |||
|                 right | |||
|             </ui:define> | |||
| 
 | |||
|             <ui:define name="content"> | |||
|                 <f:view> | |||
| 
 | |||
| 
 | |||
|                     <h:form style="background-color: white; margin: 1px;"> | |||
|                        | |||
|                         <span style="font-weight: bold; font-size: 22px">Lista de Token</span> | |||
|                       <br></br> | |||
|                         <p:commandButton action="tokenCrear.xhtml" actionListener="#{demoBeanToken.prepararNuevo()}"  value='Agregar' icon="pi pi-plus" style="margin: 10px" styleClass="ui-button-success" ajax="true"/> | |||
|                          | |||
|                         <p:dataTable value="#{demoBeanToken.listToken}" var="item" style="text-align: center;"> | |||
|                             <p:column> | |||
|                                 <f:facet name="header"> | |||
|                                     <h:outputText value="Id" style="text-align: center;"/> | |||
|                                 </f:facet> | |||
|                                 <h:outputText value="#{item.id}"/> | |||
|                             </p:column> | |||
|                             <p:column> | |||
|                                 <f:facet name="header"> | |||
|                                     <h:outputText value="Servicio" style="text-align: center;"/> | |||
|                                 </f:facet> | |||
|                                 <h:outputText value="#{item.servicio}"/> | |||
|                             </p:column> | |||
|                             <p:column> | |||
|                                 <f:facet name="header"> | |||
|                                     <h:outputText value="Token" style="text-align: center;"/> | |||
|                                 </f:facet> | |||
|                                 <h:outputText value="#{item.token}"/> | |||
|                             </p:column> | |||
|                             <p:column> | |||
|                                 <f:facet name="header"> | |||
|                                     <h:outputText value="Fecha de Registro" style="text-align: center;"/> | |||
|                                 </f:facet> | |||
|                                 <h:outputText value="#{item.fecha}"> | |||
|                                     <f:convertDateTime pattern="MM/dd/yyyy" /> | |||
|                                 </h:outputText> | |||
|                             </p:column> | |||
|                             <p:column> | |||
|                                 <f:facet name="header"> | |||
|                                     <h:outputText value="Opciones" style="text-align: center;"/> | |||
|                                 </f:facet> | |||
|                                  <p:commandButton action="tokenEliminar.xhtml" icon="pi pi-trash" styleClass="rounded-button ui-button-danger ui-button-flat" actionListener="#{demoBeanToken.prepararEliminar(item)}" ajax="false"/> | |||
|                             </p:column> | |||
|    | |||
|                         </p:dataTable> | |||
|                          | |||
|                     </h:form> | |||
|                 </f:view> | |||
| 
 | |||
|                  | |||
|             </ui:define> | |||
| 
 | |||
|             <ui:define name="bottom"> | |||
|                 bottom | |||
|             </ui:define> | |||
|              | |||
|              | |||
| 
 | |||
|         </ui:composition> | |||
|         <script> | |||
|         $.fn.dataTable.ext.errMode = 'none';         | |||
|         new DataTable('table'); | |||
|         </script> | |||
|          | |||
| 
 | |||
|     </body> | |||
| </html> | |||
					Loading…
					
					
				
		Reference in new issue