You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
3.5 KiB
126 lines
3.5 KiB
/*
|
|
* 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 xforce.vista;
|
|
|
|
import javax.inject.Named;
|
|
import javax.enterprise.context.SessionScoped;
|
|
import java.io.Serializable;
|
|
import java.util.List;
|
|
import javax.ejb.EJB;
|
|
import org.primefaces.PrimeFaces;
|
|
import xforce.bl.PaisesBLLocal;
|
|
import xforce.modelo.Paises;
|
|
import xforce.modelo.Producto;
|
|
import xforce.modelo.Tipo;
|
|
import xforce.msg.Mensaje;
|
|
import static xforce.msg.Mensaje.CAMPOS_INCOMPLETOS;
|
|
import static xforce.msg.Mensaje.DATOS_INCORRECTOS;
|
|
import static xforce.msg.Mensaje.ELEMENTO_DUPLICADO;
|
|
import static xforce.msg.Mensaje.SIN_ERROR;
|
|
|
|
/**
|
|
*
|
|
* @author Samuel Gamez
|
|
*/
|
|
@Named(value = "demoBeanPaises")
|
|
@SessionScoped
|
|
public class DemoBeanPaises implements Serializable {
|
|
|
|
@EJB
|
|
private PaisesBLLocal paisesBL;
|
|
|
|
/**
|
|
* Creates a new instance of DemoBeaPaises
|
|
*/
|
|
public DemoBeanPaises() {
|
|
}
|
|
|
|
private Paises paises = new Paises();
|
|
|
|
private String titulo;
|
|
|
|
private boolean nuevo;
|
|
|
|
public List<Paises> getPaises() {
|
|
return paisesBL.buscarValidos(true);
|
|
}
|
|
|
|
public Paises getPais() {
|
|
return paises;
|
|
}
|
|
|
|
public void setPais(Paises paises) {
|
|
this.paises = paises;
|
|
}
|
|
|
|
public String getTitulo() {
|
|
return titulo;
|
|
}
|
|
|
|
public void setTitulo(String titulo) {
|
|
this.titulo = titulo;
|
|
}
|
|
|
|
public String agregarPais() {
|
|
|
|
Mensaje mensaje = paisesBL.agregar(paises);
|
|
|
|
switch (mensaje) {
|
|
case SIN_ERROR:
|
|
paises = new Paises();
|
|
PrimeFaces.current().ajax().update("marcaTable:messages");
|
|
PrimeFaces.current().ajax().update("userTable:messages");
|
|
PrimeFaces.current().ajax().update("productoTable:messages");
|
|
return null;//"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 String editarProducto() {
|
|
|
|
Mensaje mensaje = paisesBL.editar(paises);
|
|
|
|
switch (mensaje) {
|
|
case SIN_ERROR:
|
|
paises = new Paises();
|
|
PrimeFaces.current().ajax().update("marcaTable:messages");
|
|
PrimeFaces.current().ajax().update("userTable:messages");
|
|
PrimeFaces.current().ajax().update("productoTable:messages");
|
|
return "productoLista.xhtml"; // 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 void eliminarPais(Paises paises) {
|
|
nuevo = false;
|
|
this.paises = paises;
|
|
paisesBL.eliminar(paises);
|
|
PrimeFaces.current().ajax().update("marcaTable:messages");
|
|
PrimeFaces.current().ajax().update("userTable:messages");
|
|
PrimeFaces.current().ajax().update("productoTable:messages");
|
|
|
|
}
|
|
|
|
public void prepararNuevo() {
|
|
nuevo = true;
|
|
paises = new Paises();
|
|
}
|
|
}
|
|
|