private void persist(PersistAction persistAction, String successMessage) {
   if (selected != null) {
     setEmbeddableKeys();
     try {
       if (persistAction != PersistAction.DELETE) {
         getFacade().edit(selected);
       } else {
         getFacade().remove(selected);
       }
       JsfUtil.addSuccessMessage(successMessage);
     } catch (EJBException ex) {
       String msg = "";
       Throwable cause = ex.getCause();
       if (cause != null) {
         msg = cause.getLocalizedMessage();
       }
       if (msg.length() > 0) {
         JsfUtil.addErrorMessage(msg);
       } else {
         JsfUtil.addErrorMessage(
             ex, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
       }
     } catch (Exception ex) {
       Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
       JsfUtil.addErrorMessage(
           ex, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
     }
   }
 }
Exemplo n.º 2
0
 private void performDestroy() {
   try {
     getFacade().remove(current);
     JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("StCicloDeleted"));
   } catch (Exception e) {
     JsfUtil.addErrorMessage(
         e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
   }
 }
Exemplo n.º 3
0
 public String update() {
   try {
     getFacade().edit(current);
     JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("StCicloUpdated"));
     return "View";
   } catch (Exception e) {
     JsfUtil.addErrorMessage(
         e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
     return null;
   }
 }
Exemplo n.º 4
0
 public String create() {
   try {
     current.setCodigoCiclo(0);
     getFacade().create(current);
     JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("StCicloCreated"));
     return prepareCreate();
   } catch (Exception e) {
     JsfUtil.addErrorMessage(
         e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
     return null;
   }
 }
 public void destroy() {
   persist(PersistAction.DELETE, ResourceBundle.getBundle("/Bundle").getString("VentasDeleted"));
   if (!JsfUtil.isValidationFailed()) {
     selected = null; // Remove selection
     items = null; // Invalidate list of items to trigger re-query.
   }
 }
 public void create() {
   persist(
       PersistAction.CREATE, ResourceBundle.getBundle("/Bundle").getString("ProductosCreated"));
   if (!JsfUtil.isValidationFailed()) {
     items = null; // Invalidate list of items to trigger re-query.
   }
 }
Exemplo n.º 7
0
 public SelectItem[] getItemsAvailableSelectOne() {
   return JsfUtil.getSelectItems(ejbFacade.findAll(), true);
 }
Exemplo n.º 8
0
 public SelectItem[] getItemsAvailableSelectMany() {
   return JsfUtil.getSelectItems(ejbFacade.findAll(), false);
 }