From a45f6817705b1e4e5da42f39b3e5c0675c755180 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 10 May 2016 14:16:41 +0200 Subject: [PATCH] Continued a bit: - don't return full list as the JSF seems to modify it ??? - always use this.someList and not allFoos() - moved allMobileProviders() and hasMobileProviders() to regular controller as this one holds the cached list anyway - renamed mobileController -> mobileProviderController - call bean again instead of getting same (!) list: this fixes a bug that a lot contacts has been removed from the list - careful cherry-picking this: recruiter-related changes are included and contact EJB added! MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../AddressbookContactWebSessionBean.java | 6 +++--- .../AddressbookCountryWebApplicationBean.java | 4 ++-- ...essbookAdminMobileProviderWebRequestBean.java | 12 +----------- ...kAdminMobileProviderWebRequestController.java | 16 ---------------- .../AddressbookMobileProviderWebRequestBean.java | 11 ++++++++--- ...ssbookMobileProviderWebRequestController.java | 7 +++++++ .../user/AddressbookUserWebSessionBean.java | 2 +- .../templates/generic/mobile_selection_box.tpl | 2 +- .../admin_mobile_provider_list.xhtml | 2 +- 9 files changed, 24 insertions(+), 38 deletions(-) diff --git a/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java index d8611e09..725b928f 100644 --- a/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java @@ -17,6 +17,7 @@ package org.mxchange.addressbook.beans.contact; import java.text.MessageFormat; +import java.util.Collections; import java.util.Date; import java.util.Iterator; import java.util.List; @@ -382,13 +383,12 @@ public class AddressbookContactWebSessionBean implements AddressbookContactWebSe } @Override - @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allContacts () { // Debug message /* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactController.allContacts: contactList.size()={0} - EXIT!", this.contactList.size())); // Return un-modified list - return this.contactList; + return Collections.unmodifiableList(this.contactList); } @Override @@ -742,7 +742,7 @@ public class AddressbookContactWebSessionBean implements AddressbookContactWebSe @Override public boolean hasContacts () { - return (!this.allContacts().isEmpty()); + return (!this.contactList.isEmpty()); } /** diff --git a/src/java/org/mxchange/addressbook/beans/country/AddressbookCountryWebApplicationBean.java b/src/java/org/mxchange/addressbook/beans/country/AddressbookCountryWebApplicationBean.java index 6b3668cf..e87eddda 100644 --- a/src/java/org/mxchange/addressbook/beans/country/AddressbookCountryWebApplicationBean.java +++ b/src/java/org/mxchange/addressbook/beans/country/AddressbookCountryWebApplicationBean.java @@ -17,6 +17,7 @@ package org.mxchange.addressbook.beans.country; import java.text.MessageFormat; +import java.util.Collections; import java.util.List; import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; @@ -93,10 +94,9 @@ public class AddressbookCountryWebApplicationBean implements AddressbookCountryW } @Override - @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allCountries () { // Return "cached" version - return this.countryList; + return Collections.unmodifiableList(this.countryList); } /** diff --git a/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestBean.java index 5b052c51..b6d511b9 100644 --- a/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestBean.java @@ -134,11 +134,6 @@ public class AddressbookAdminMobileProviderWebRequestBean implements Addressbook return "admin_list_mobile_provider"; //NOI18N } - @Override - public List allMobileProvider () { - return this.mobileController.allMobileProvider(); - } - @Override public Country getProviderCountry () { return this.providerCountry; @@ -179,11 +174,6 @@ public class AddressbookAdminMobileProviderWebRequestBean implements Addressbook this.providerName = providerName; } - @Override - public boolean hasMobileProvider () { - return (!this.allMobileProvider().isEmpty()); - } - /** * Checks whether if the given mobile provider is already created by * checking both dial prefix and country. @@ -197,7 +187,7 @@ public class AddressbookAdminMobileProviderWebRequestBean implements Addressbook boolean isFound = false; // Get list of all providers - List providers = this.allMobileProvider(); + List providers = this.mobileController.allMobileProvider(); // Get iterator from it Iterator iterator = providers.iterator(); diff --git a/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestController.java b/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestController.java index d287dd2b..e3dd484c 100644 --- a/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestController.java +++ b/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookAdminMobileProviderWebRequestController.java @@ -17,9 +17,7 @@ package org.mxchange.addressbook.beans.mobileprovider; import java.io.Serializable; -import java.util.List; import org.mxchange.jcountry.data.Country; -import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider; /** * An interface for a request web controller (bean) for administrative mobile @@ -38,20 +36,6 @@ public interface AddressbookAdminMobileProviderWebRequestController extends Seri */ String addMobileProvider (); - /** - * Returns a list of all mobile providers - *

- * @return A list of all mobile providers - */ - List allMobileProvider (); - - /** - * Checks whether mobile providers are registered - *

- * @return Whether mobile providers are registered - */ - boolean hasMobileProvider (); - /** * Getter for provider dial prefix *

diff --git a/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookMobileProviderWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookMobileProviderWebRequestBean.java index 8a4a356b..408accfd 100644 --- a/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookMobileProviderWebRequestBean.java @@ -17,6 +17,7 @@ package org.mxchange.addressbook.beans.mobileprovider; import java.text.MessageFormat; +import java.util.Collections; import java.util.List; import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; @@ -35,7 +36,7 @@ import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProviderSingletonBe *

* @author Roland Haeder */ -@Named ("mobileController") +@Named ("mobileProviderController") @SessionScoped public class AddressbookMobileProviderWebRequestBean implements AddressbookMobileProviderWebRequestController { @@ -93,9 +94,13 @@ public class AddressbookMobileProviderWebRequestBean implements AddressbookMobil } @Override - @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allMobileProvider () { - return this.mobileProviders; + return Collections.unmodifiableList(this.mobileProviders); + } + + @Override + public boolean hasMobileProvider () { + return (!this.mobileProviders.isEmpty()); } /** diff --git a/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookMobileProviderWebRequestController.java b/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookMobileProviderWebRequestController.java index 40929131..49091411 100644 --- a/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookMobileProviderWebRequestController.java +++ b/src/java/org/mxchange/addressbook/beans/mobileprovider/AddressbookMobileProviderWebRequestController.java @@ -35,6 +35,13 @@ public interface AddressbookMobileProviderWebRequestController extends Serializa */ List allMobileProvider (); + /** + * Checks whether mobile providers are registered + *

+ * @return Whether mobile providers are registered + */ + boolean hasMobileProvider (); + /** * Observes events being fired after the administrator has added a new * mobile provider diff --git a/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java index 74a8975c..2d13c89d 100644 --- a/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java @@ -512,7 +512,7 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC List allUsers = this.allUsers(); // Get all contacts - List allContacts = this.contactController.allContacts(); + List allContacts = this.contactBean.getAllContacts(); // Get iterator Iterator iterator = allContacts.iterator(); diff --git a/web/WEB-INF/templates/generic/mobile_selection_box.tpl b/web/WEB-INF/templates/generic/mobile_selection_box.tpl index 14515170..a76aafeb 100644 --- a/web/WEB-INF/templates/generic/mobile_selection_box.tpl +++ b/web/WEB-INF/templates/generic/mobile_selection_box.tpl @@ -8,7 +8,7 @@ - + diff --git a/web/admin/mobile_provider/admin_mobile_provider_list.xhtml b/web/admin/mobile_provider/admin_mobile_provider_list.xhtml index 9d03373c..bf450a76 100644 --- a/web/admin/mobile_provider/admin_mobile_provider_list.xhtml +++ b/web/admin/mobile_provider/admin_mobile_provider_list.xhtml @@ -16,7 +16,7 @@ - + #{msg.ADMIN_LIST_MOBILE_PROVIDER_ID} -- 2.39.5