コード例 #1
0
 private void persist(PersistAction persistAction, String successMessage) {
   if (selected != null) {
     setEmbeddableKeys();
     try {
       if (persistAction != PersistAction.DELETE) {
         getFacade().edit(selected);
       } else {
         getFacade().inactivate(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) {
       LOG.log(Level.ERROR, ex.getMessage(), ex);
       JsfUtil.addErrorMessage(
           ex, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
     }
   }
 }
コード例 #2
0
 public void create() {
   persist(
       PersistAction.CREATE, ResourceBundle.getBundle("/Bundle").getString("PrioritiesCreated"));
   if (!JsfUtil.isValidationFailed()) {
     items = null; // Invalidate list of items to trigger re-query.
   }
 }
コード例 #3
0
 public void destroy() {
   persist(
       PersistAction.DELETE, ResourceBundle.getBundle("/Bundle").getString("PrioritiesDeleted"));
   if (!JsfUtil.isValidationFailed()) {
     selected = null; // Remove selection
     items = null; // Invalidate list of items to trigger re-query.
   }
 }