Пример #1
0
 private Child persist(PersistAction persistAction, Child child, String successMessage) {
   System.out.println("PERSIST");
   Child ret = null;
   if (child != null) {
     setEmbeddableKeys();
     try {
       if (persistAction != PersistAction.DELETE) {
         ret = getFacade().edit(child);
       } else {
         getFacade().remove(child);
       }
       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"));
     }
   }
   return ret;
 }
Пример #2
0
 public void destroy(Child child) {
   System.out.println("DESTROY");
   persist(
       PersistAction.DELETE, child, ResourceBundle.getBundle("/Bundle").getString("ChildDeleted"));
   if (!JsfUtil.isValidationFailed()) {
     // selected = null; // Remove selection
     items = null; // Invalidate list of items to trigger re-query.
   }
 }
Пример #3
0
 //  public EventType prepareCreate() {
 //    created = new EventType();
 //    initializeEmbeddableKey();
 //    return created;
 //  }
 public Child create(Child newChild) {
   System.out.println("CREATE");
   Child ret =
       persist(
           PersistAction.CREATE,
           newChild,
           MessageFormat.format(
               ResourceBundle.getBundle("/Bundle").getString("ChildCreated"),
               newChild.getFirstname()));
   if (!JsfUtil.isValidationFailed()) {
     items = null; // Invalidate list of items to trigger re-query.
   }
   return ret;
 }