]> git.mxchange.org Git - jfinancials-war.git/blobdiff - src/java/org/mxchange/jfinancials/beans/contact/FinancialsContactWebRequestBean.java
Updated copyright year
[jfinancials-war.git] / src / java / org / mxchange / jfinancials / beans / contact / FinancialsContactWebRequestBean.java
index 19c41c8e8466816db4c4b33f33e84f6fb30b0d58..29316ec548ef7a859163a976abc54389c4268bf3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 - 2020 Free Software Foundation
+ * Copyright (C) 2016 - 2022 Free Software Foundation
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
@@ -21,11 +21,16 @@ import java.util.Date;
 import java.util.Objects;
 import javax.ejb.EJB;
 import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
 import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
 import javax.faces.FacesException;
 import javax.faces.application.FacesMessage;
 import javax.inject.Inject;
 import javax.inject.Named;
+import org.mxchange.jcontacts.events.contact.update.ObservableUpdatedContactEvent;
+import org.mxchange.jcontacts.events.contact.update.UpdatedContactEvent;
+import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
 import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jcontacts.model.contact.ContactSessionBeanRemote;
 import org.mxchange.jcontacts.model.contact.Contacts;
@@ -93,6 +98,13 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
         */
        private FinancialsContactListWebViewController contactListController;
 
+       /**
+        * Event being fired when a user has updated his contact data
+        */
+       @Any
+       @Inject
+       private Event<ObservableUpdatedContactEvent> contactUpdatedEvent;
+
        /**
         * Country instance
         */
@@ -368,8 +380,19 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
                // Update contact's fax number
                final boolean isFaxUnlinked = Contacts.updateFaxNumber(contact, this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
 
-               // Send it to the EJB
-               this.contactBean.updateContactData(contact, isMobileUnlinked, isLandLineUnlinked, isFaxUnlinked);
+               // Init updated contact instance
+               final Contact updatedContact;
+
+               try {
+                       // Send it to the EJB
+                       updatedContact = this.contactBean.updateContactData(contact, isMobileUnlinked, isLandLineUnlinked, isFaxUnlinked);
+               } catch (final ContactNotFoundException ex) {
+                       // Throw as cause
+                       throw new FacesException(ex);
+               }
+
+               // Fire event
+               this.contactUpdatedEvent.fire(new UpdatedContactEvent(updatedContact));
 
                // All fine
                return "contact_data_saved"; //NOI18N
@@ -449,17 +472,6 @@ public class FinancialsContactWebRequestBean extends BaseFinancialsBean implemen
                this.comment = comment;
        }
 
-       @Override
-       public String getControllerType () {
-               return "general"; //NOI18N
-       }
-
-       @Override
-       @Deprecated
-       public void setControllerType (final String controllerType) {
-               throw new UnsupportedOperationException("Setting controller type is not supported."); //NOI18N
-       }
-
        /**
         * Getter for country instance
         * <p>