]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Continued with contacts:
authorRoland Häder <roland@mxchange.org>
Wed, 27 Apr 2016 06:52:40 +0000 (08:52 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 29 Apr 2016 19:23:51 +0000 (21:23 +0200)
- added hasContacts() / allContacts()
- listing of contacts started, maybe later add a method that checks where the contact is being used and returns a message key?

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java
src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java
src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionController.java
web/admin/contact/admin_contact_list.xhtml

index 3e1826f00166f7fac0131d995fbd718a2dc83862..6c1a48310692ca83ccab29f192e2978acc030aa8 100644 (file)
@@ -112,6 +112,12 @@ public class AddressbookAdminContactWebRequestBean implements AddressbookAdminCo
         */
        private final ContactSessionBeanRemote contactBean;
 
+       /**
+        * General contact controller
+        */
+       @Inject
+       private AddressbookContactWebSessionController contactController;
+
        /**
         * Contact id
         */
@@ -292,39 +298,6 @@ public class AddressbookAdminContactWebRequestBean implements AddressbookAdminCo
                return this.contactController.allContacts();
        }
 
-       @Override
-       public String changeContactData () {
-               // Get contact instance
-               Contact contact = this.adminHelper.getContact();
-
-               // Default is not same contact
-               if (this.isSameContactFound(contact)) {
-                       // Already registered
-                       throw new FaceletException(new ContactAlreadyAddedException(contact));
-               }
-
-               // Init contact
-               Contact updatedContact;
-
-               // Try to call EJB
-               try {
-                       // Call EJB
-                       updatedContact = this.contactBean.addContact(contact);
-               } catch (final ContactAlreadyAddedException ex) {
-                       // Throw again
-                       throw new FaceletException(ex);
-               }
-
-               // Fire event
-               this.addedContactEvent.fire(new AdminContactAddedEvent(updatedContact));
-
-               // Clear this bean
-               this.clear();
-
-               // Return outcome
-               return "admin_list_contact"; //NOI18N
-       }
-
        @Override
        public void copyContactToController (final Contact contact) {
                // The contact instance must be valid
@@ -659,6 +632,11 @@ public class AddressbookAdminContactWebRequestBean implements AddressbookAdminCo
                this.zipCode = zipCode;
        }
 
+       @Override
+       public boolean hasContacts () {
+               return (!this.allContacts().isEmpty());
+       }
+
        /**
         * Post-initialization of this class
         */
index e06149a3acbae6282612a4585f93843fb6bac0a3..310508de43d33a26dbc03caefc9b292b634edb66 100644 (file)
@@ -229,7 +229,7 @@ public class AddressbookContactWebSessionBean implements AddressbookContactWebSe
        @Override
        public void afterAdminUpdatedContactDataEvent (@Observes final AdminUpdatedContactEvent event) {
                // Trace message
-               System.out.println(MessageFormat.format("ContactWebBean:afterAdminUpdatedContactDataEvent: event={0} - CALLED!", event)); //NOI18N
+               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterAdminUpdatedContactDataEvent: event={0} - CALLED!", event)); //NOI18N
 
                // event should not be null
                if (null == event) {
@@ -275,7 +275,7 @@ public class AddressbookContactWebSessionBean implements AddressbookContactWebSe
        @Override
        public void afterRegistrationEvent (final @Observes UserRegisteredEvent event) {
                // Trace message
-               System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
+               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
 
                // event should not be null
                if (null == event) {
@@ -296,7 +296,7 @@ public class AddressbookContactWebSessionBean implements AddressbookContactWebSe
                Contact registeredContact = event.getRegisteredUser().getUserContact();
 
                // Debug message
-               System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: registeredContact={0}", registeredContact)); //NOI18N
+               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterRegistration: registeredContact={0}", registeredContact)); //NOI18N
 
                // Copy all data from registered->user
                this.copyContact(registeredContact);
@@ -308,13 +308,13 @@ public class AddressbookContactWebSessionBean implements AddressbookContactWebSe
                this.clear();
 
                // Trace message
-               System.out.println("ContactWebBean:afterRegistration: EXIT!"); //NOI18N
+               //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterRegistration: EXIT!"); //NOI18N
        }
 
        @Override
        public void afterUserLogin (final @Observes UserLoggedInEvent event) {
                // Trace message
-               System.out.println(MessageFormat.format("ContactWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
+               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
 
                // event should not be null
                if (null == event) {
@@ -335,10 +335,11 @@ public class AddressbookContactWebSessionBean implements AddressbookContactWebSe
                this.copyContact(event.getLoggedInUser().getUserContact());
 
                // Trace message
-               System.out.println("ContactWebBean:afterUserLogin - EXIT!"); //NOI18N
+               //* NOISY-DEBUG: */ System.out.println("ContactWebBean:afterUserLogin - EXIT!"); //NOI18N
        }
 
        @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       @Override
        public List<Contact> allContacts () {
                return this.contactList;
        }
index 39998c6cae1bc00ba6f384334ced8f7a12a9745e..378137d167b9ccdbdc123aeb52c50b57c63578cd 100644 (file)
@@ -18,6 +18,7 @@ package org.mxchange.addressbook.beans.contact;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcontacts.contact.gender.Gender;
 import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
@@ -39,6 +40,13 @@ public interface AddressbookContactWebSessionController extends Serializable {
         */
        public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
 
+       /**
+        * Returns a list of all found contacts
+        * <p>
+        * @return A list of all contacts.
+        */
+       List<Contact> allContacts();
+
        /**
         * Updates all data from bean in given contact instance
         * <p>
index b496a40772f07f78ca5c363280f21554b37ede49..dca2708a54f7f30d2ed86748891c277b3c660070 100644 (file)
@@ -1,4 +1,4 @@
-_<?xml version="1.0" encoding="UTF-8" ?>
+<?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html
        lang="#{localizationController.language}" xml:lang="#{localizationController.language}"