1.2 before/after()
Cuando necesitamos Controllar las operaciones antes o después para permitir realizar acciones previas o posteriores.
Antes y después de iniciar
 public Boolean beforeStart() {
        return true;
    } 
    public Boolean afterStart(Boolean started) {
        return started;
    } Antes/después de salvar
 public Boolean beforeSave() {
        try {
          //micodigo
            return true;
        } catch (Exception e) {
            errorServices.errorMessage(nameOfClass(), nameOfMethod(), e.getLocalizedMessage());
        }
        return false;
    }
    public Boolean afterSave(Boolean saved) {
        try {
          //micodigo
          if(saved){
          //Se guardo
          }else{
          // No se guardo
          }
   
        } catch (Exception e) {
            errorServices.errorMessage(nameOfClass(), nameOfMethod(), e.getLocalizedMessage());
        }
        return saved;
    }Antes/Después de editar
public Boolean beforeEdit() {
        try {
         //micodigo
            return true;
        } catch (Exception e) {
            errorServices.errorMessage(nameOfClass(), nameOfMethod(), e.getLocalizedMessage());
        }
        return false;
    }
 public Boolean afterEdit(Boolean edited) {
        return true;
    }Antes/Después de eliminar
    public Boolean beforeDelete() {
        try {
        //mi codigo
          return true;
        } catch (Exception e) {
            errorServices.errorMessage(nameOfClass(), nameOfMethod(), e.getLocalizedMessage());
        }
        return false;
 }
public Boolean afterDelete(Boolean deleted) {
        return true;
    }Antes/Después de eliminar  desde el list.xhtml mediante <jmoordbjsf:column>
public Boolean beforeDeleteFromListXhtml() {
        return true;
}
public Boolean afterDeleteFromListXhtml(Boolean delete) {
        return true;
    }Otros métodos
 
    
 public Boolean beforePrepareGoList() {
        return true;
    }   
    
public Boolean afterPrepareGoList(Boolean golist) {
        return golist;
    }
    
public Boolean beforePrepareGoNew() {
        return true;
    } // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="Boolean afterPrepareGoNew(Boolean gonew)">
 public Boolean afterPrepareGoNew(Boolean gonew) {
        return gonew;
    } // </editor-fold>
    
public Boolean beforePrepareNew() {
        return true;
    }
public Boolean beforeClear() {
        return true;
    }
    
Last updated
Was this helpful?