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.
 
 
 

116 lines
2.4 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.RolesBLLocal;
import xforce.modelo.Roles;
import xforce.msg.Mensaje;
/**
*
* @author hugoa
*/
@Named(value = "demoBeanRoles")
@SessionScoped
public class DemoBeanRoles implements Serializable {
@EJB
private RolesBLLocal rolesBL;
/**
* Creates a new instance of DemoBeanRoles
*/
public DemoBeanRoles() {
}
private Roles roles = new Roles();
private boolean nuevo;
private String titulo;
public String agregarRol(){
Mensaje mensaje = rolesBL.agregar(roles);
switch (mensaje) {
case SIN_ERROR:
roles = new Roles();
PrimeFaces.current().ajax().update("marcaTable:messages");
PrimeFaces.current().ajax().update("userTable:messages");
return null;
case ELEMENTO_DUPLICADO:
return null;
case CAMPOS_INCOMPLETOS:
return null;
case DATOS_INCORRECTOS:
return null;
default:
return null;
}
}
public void prepararNuevo() {
nuevo = true;
titulo = "Roles";
roles = new Roles();
}
public boolean isNuevo() {
return nuevo;
}
public void eliminarRol(Roles roles) {
nuevo=false;
this.roles = roles;
rolesBL.eliminar(roles);
PrimeFaces.current().ajax().update("marcaTable:messages");
PrimeFaces.current().ajax().update("userTable:messages");
}
public String getTitulo() {
return titulo;
}
public List<Roles> getRoles() {
return rolesBL.buscarValidos(true);
}
public Roles getRol() {
return roles;
}
public void setRol(Roles rol) {
this.roles = rol;
}
}