From 2e469aa632779932cdd6317a61b3da8f219560be 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 --- .../contact/PizzaContactWebSessionBean.java | 6 +++--- .../country/PizzaCountryWebApplicationBean.java | 4 ++-- .../PizzaAdminMobileProviderWebRequestBean.java | 12 +----------- ...aAdminMobileProviderWebRequestController.java | 16 ---------------- .../PizzaMobileProviderWebRequestBean.java | 11 ++++++++--- .../PizzaMobileProviderWebRequestController.java | 7 +++++++ .../beans/user/PizzaUserWebSessionBean.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/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java index dc5d524c..fae504f3 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/contact/PizzaContactWebSessionBean.java @@ -17,6 +17,7 @@ package org.mxchange.pizzaapplication.beans.contact; import java.text.MessageFormat; +import java.util.Collections; import java.util.Date; import java.util.Iterator; import java.util.List; @@ -407,13 +408,12 @@ public class PizzaContactWebSessionBean implements PizzaContactWebSessionControl } @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 @@ -764,7 +764,7 @@ public class PizzaContactWebSessionBean implements PizzaContactWebSessionControl @Override public boolean hasContacts () { - return (!this.allContacts().isEmpty()); + return (!this.contactList.isEmpty()); } /** diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationBean.java index 78be1b4d..623ced51 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaCountryWebApplicationBean.java @@ -17,6 +17,7 @@ package org.mxchange.pizzaapplication.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 PizzaCountryWebApplicationBean implements PizzaCountryWebApplicatio } @Override - @SuppressWarnings ("ReturnOfCollectionOrArrayField") public List allCountries () { // Return "cached" version - return this.countryList; + return Collections.unmodifiableList(this.countryList); } /** diff --git a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java index 056de736..4c2c3f47 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestBean.java @@ -137,11 +137,6 @@ public class PizzaAdminMobileProviderWebRequestBean implements PizzaAdminMobileP return "admin_list_mobile_provider"; //NOI18N } - @Override - public List allMobileProvider () { - return this.mobileController.allMobileProvider(); - } - @Override public Country getProviderCountry () { return this.providerCountry; @@ -182,11 +177,6 @@ public class PizzaAdminMobileProviderWebRequestBean implements PizzaAdminMobileP this.providerName = providerName; } - @Override - public boolean hasMobileProvider () { - return (!this.allMobileProvider().isEmpty()); - } - /** * Clears this bean */ @@ -211,7 +201,7 @@ public class PizzaAdminMobileProviderWebRequestBean implements PizzaAdminMobileP 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/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestController.java b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestController.java index 14e74bab..65e2aa7a 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaAdminMobileProviderWebRequestController.java @@ -17,9 +17,7 @@ package org.mxchange.pizzaapplication.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 PizzaAdminMobileProviderWebRequestController extends Serializab */ 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/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java index 9c77a095..ce478f68 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestBean.java @@ -17,6 +17,7 @@ package org.mxchange.pizzaapplication.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 PizzaMobileProviderWebRequestBean implements PizzaMobileProviderWebRequestController { @@ -93,9 +94,13 @@ public class PizzaMobileProviderWebRequestBean implements PizzaMobileProviderWeb } @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/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestController.java b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestController.java index 29fe878a..d1e15811 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/mobileprovider/PizzaMobileProviderWebRequestController.java @@ -35,6 +35,13 @@ public interface PizzaMobileProviderWebRequestController extends Serializable { */ 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/pizzaapplication/beans/user/PizzaUserWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java index fda56cd5..d1eb853c 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java @@ -513,7 +513,7 @@ public class PizzaUserWebSessionBean implements PizzaUserWebSessionController { 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