/*
- * 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
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;
*/
private FinancialsContactListWebViewController contactListController;
+ /**
+ * Event being fired when a user has updated his contact data
+ */
+ @Any
+ @Inject
+ private Event<ObservableUpdatedContactEvent> contactUpdatedEvent;
+
/**
* Country instance
*/
// 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
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>