]> git.mxchange.org Git - jjobs-war.git/commitdiff
Continued with adding countries:
authorRoland Haeder <roland@mxchange.org>
Mon, 11 Apr 2016 16:27:48 +0000 (18:27 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 11 Apr 2016 16:32:25 +0000 (18:32 +0200)
- admin country controller (class + interface) added
- added admin form template for country data
- added admin list/edit/delete pages for countries
- added table_medium, table_left_medium, table_right_medium CSS classes
- changed named phoneCountryCode to countryPhoneCode (naming convention)
- other minor stuff mixed

Signed-off-by: Roland Häder <roland@mxchange.org>
14 files changed:
nbproject/faces-config.NavData
src/java/org/mxchange/localization/bundle_de_DE.properties
src/java/org/mxchange/localization/bundle_en_US.properties
src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebApplicationBean.java [new file with mode: 0644]
src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebApplicationController.java [new file with mode: 0644]
web/WEB-INF/faces-config.xml
web/WEB-INF/templates/admin/admin_form_country_data.tpl [new file with mode: 0644]
web/WEB-INF/templates/admin/admin_form_personal_data.tpl
web/WEB-INF/templates/admin/admin_menu.tpl
web/WEB-INF/templates/generic/form_personal_data.tpl
web/admin/admin_country_delete.xhtml [new file with mode: 0644]
web/admin/admin_country_edit.xhtml [new file with mode: 0644]
web/admin/admin_country_list.xhtml [new file with mode: 0644]
web/resources/css/cssLayout.css

index f90dec7819c30c30ad4a9ccb9e1ec9c863082530..7a5b9fb64c1c846c1f2dd433f2f52ea2c404d7be 100644 (file)
@@ -2,38 +2,41 @@
 <Scene Scope="Project" version="2">
     <Scope Scope="Faces Configuration Only"/>
     <Scope Scope="Project">
-        <Node id="admin/admin_user_delete.xhtml" x="150" y="1050" zoom="true"/>
-        <Node id="privacy.xhtml" x="150" y="150" zoom="true"/>
-        <Node id="login/login_change_password.xhtml" x="650" y="300" zoom="true"/>
-        <Node id="admin/index.xhtml" x="900" y="450" zoom="true"/>
-        <Node id="login/login_data_saved.xhtml" x="900" y="300" zoom="true"/>
-        <Node id="user/register.xhtml" x="400" y="450" zoom="true"/>
-        <Node id="login/login_all_applications.xhtml" x="650" y="450" zoom="true"/>
-        <Node id="user/resend_link.xhtml" x="400" y="150" zoom="true"/>
-        <Node id="login/login_index.xhtml" x="1400" y="150" zoom="true"/>
-        <Node id="login/login_add_addressbook.xhtml" x="400" y="900" zoom="true"/>
-        <Node id="login/login_own_addressbooks.xhtml" x="400" y="300" zoom="true"/>
-        <Node id="admin/admin_user_list.xhtml" x="650" y="600" zoom="true"/>
-        <Node id="terms.xhtml" x="150" y="600" zoom="true"/>
-        <Node id="admin/admin_logout.xhtml" x="1150" y="300" zoom="true"/>
+        <Node id="admin/admin_country_list.xhtml" x="650" y="450" zoom="true"/>
+        <Node id="admin/admin_user_delete.xhtml" x="400" y="150" zoom="true"/>
+        <Node id="login/login_change_password.xhtml" x="650" y="150" zoom="true"/>
+        <Node id="privacy.xhtml" x="900" y="750" zoom="true"/>
+        <Node id="admin/index.xhtml" x="900" y="600" zoom="true"/>
+        <Node id="login/login_data_saved.xhtml" x="1150" y="600" zoom="true"/>
+        <Node id="admin/admin_country_delete.xhtml" x="1650" y="300" zoom="true"/>
+        <Node id="user/register.xhtml" x="150" y="450" zoom="true"/>
+        <Node id="login/login_all_applications.xhtml" x="650" y="300" zoom="true"/>
+        <Node id="admin/admin_country_edit.xhtml" x="1400" y="300" zoom="true"/>
+        <Node id="user/resend_link.xhtml" x="900" y="300" zoom="true"/>
+        <Node id="login/login_add_addressbook.xhtml" x="1400" y="150" zoom="true"/>
+        <Node id="login/login_index.xhtml" x="900" y="450" zoom="true"/>
+        <Node id="login/login_own_addressbooks.xhtml" x="400" y="750" zoom="true"/>
+        <Node id="admin/admin_user_list.xhtml" x="650" y="900" zoom="true"/>
+        <Node id="admin/admin_logout.xhtml" x="150" y="1050" zoom="true"/>
+        <Node id="terms.xhtml" x="400" y="1050" zoom="true"/>
         <Node id="admin/admin_user_add.xhtml" x="400" y="600" zoom="true"/>
-        <Node id="admin/admin_user_edit.xhtml" x="1900" y="150" zoom="true"/>
-        <Node id="user/user_list.xhtml" x="1650" y="300" zoom="true"/>
-        <Node id="index.xhtml" x="1400" y="450" zoom="true"/>
-        <Node id="logout.xhtml" x="900" y="600" zoom="true"/>
-        <Node id="user/register_done.xhtml" x="150" y="900" zoom="true"/>
-        <Node id="user/user_profile.xhtml" x="650" y="150" zoom="true"/>
-        <Node id="login/login_change_personal_data.xhtml" x="1400" y="300" zoom="true"/>
-        <Node id="admin/admin_user_unlock.xhtml" x="150" y="300" zoom="true"/>
-        <Node id="user/show_addressbook.xhtml" x="400" y="750" zoom="true"/>
+        <Node id="admin/admin_user_edit.xhtml" x="1150" y="300" zoom="true"/>
+        <Node id="user/user_list.xhtml" x="150" y="900" zoom="true"/>
+        <Node id="index.xhtml" x="650" y="750" zoom="true"/>
+        <Node id="logout.xhtml" x="900" y="150" zoom="true"/>
+        <Node id="user/register_done.xhtml" x="400" y="900" zoom="true"/>
+        <Node id="login/login_change_personal_data.xhtml" x="650" y="600" zoom="true"/>
+        <Node id="user/user_profile.xhtml" x="1900" y="150" zoom="true"/>
+        <Node id="admin/admin_user_unlock.xhtml" x="150" y="600" zoom="true"/>
+        <Node id="user/show_addressbook.xhtml" x="150" y="300" zoom="true"/>
+        <Node id="*" x="1150" y="150" zoom="true"/>
         <Node id="imprint.xhtml" x="1650" y="150" zoom="true"/>
-        <Node id="*" x="1150" y="600" zoom="true"/>
-        <Node id="user/login_error.xhtml" x="650" y="750" zoom="true"/>
-        <Node id="user/show_addressbook_entries.xhtml" x="1150" y="150" zoom="true"/>
-        <Node id="login/login_change_email_address.xhtml" x="150" y="450" zoom="true"/>
-        <Node id="user/lost_passwd.xhtml" x="900" y="150" zoom="true"/>
-        <Node id="user/login.xhtml" x="1150" y="450" zoom="true"/>
-        <Node id="login/login_edit_user_data.xhtml" x="150" y="750" zoom="true"/>
+        <Node id="user/login_error.xhtml" x="1150" y="450" zoom="true"/>
+        <Node id="user/show_addressbook_entries.xhtml" x="150" y="750" zoom="true"/>
+        <Node id="login/login_change_email_address.xhtml" x="150" y="150" zoom="true"/>
+        <Node id="user/lost_passwd.xhtml" x="400" y="450" zoom="true"/>
+        <Node id="user/login.xhtml" x="1400" y="450" zoom="true"/>
+        <Node id="login/login_edit_user_data.xhtml" x="400" y="300" zoom="true"/>
     </Scope>
     <Scope Scope="All Faces Configurations"/>
 </Scene>
index cb5a8c167c04ae11784f4db07980700dc838762a..7f8a7caf36d37c3ea279d90725986575167c9d34 100644 (file)
@@ -350,3 +350,49 @@ ADMIN_ADD_USER_EMAIL_ADDRESS_NOTICE=*2: Die Email-Adresse darf nur einmal vorhan
 ADMIN_ADD_USER_CUSTOMER_NUMBER_NOTICE=Eine Kundennummer wird automatisch beim Erstellen des Accounts erzeugt.
 #@TODO Please fix German umlauts!
 BUTTON_ADMIN_ADD_USER=Neuen Benutzer hinzufuegen
+#@TODO Please fix German umlauts!
+ADMIN_MENU_COUNTRY_TITLE=Laenderdaten
+#@TODO Please fix German umlauts!
+LINK_ADMIN_LIST_COUNTRIES=Laender auflisten
+#@TODO Please fix German umlauts!
+LINK_ADMIN_LIST_COUNTRIES_TITLE=Bestehende Laenderdaten auflisten, neue hinzufuegen, aendern und loeschen.
+#@TODO Please fix German umlauts!
+PAGE_TITLE_ADMIN_LIST_COUNTRY=Laenderdaten verwalten
+#@TODO Please fix German umlauts!
+CONTENT_TITLE_ADMIN_LIST_COUNTRY=Laenderdaten verwalten:
+#@TODO Please fix German umlauts!
+ADMIN_ADD_COUNTRY_TITLE=Neues Land hinzufuegen
+ADMIN_COUNTRY_DATA_MINIMUM_NOTICE=Bitte geben Sie alle Felder an.
+#@TODO Please fix German umlauts!
+ADMIN_ADD_COUNTRY_I18N_KEY_NOTICE=Der Schluessel fuer das Sprachpaket ist in Grossbuchstaben und Unterstrichen zu schreiben. Beispiel: COUNTRY_GERMANY fuer Deutschland
+#@TODO Please fix German umlauts!
+ADMIN_ADD_COUNTRY_NOTICES=Hinweise fuer Laenderdaten:
+#@TODO Please fix German umlauts!
+ADMIN_COUNTRY_PHONE_DATA_LEGEND=Laenderdaten und Telefon:
+#@TODO Please fix German umlauts!
+ADMIN_COUNTRY_PHONE_DATA_LEGEND_TITLE=Geben Sie hier Daten zum Land ein, wie auch Daten fuer Telefonnummern, wie z.B. Vorwahl fuer Auslandsgespraeche.
+#@TODO Please fix German umlauts!
+ADMIN_ENTER_COUNTRY_ABROAD_DIAL_PREFIX=Vorwahl fuer Auslandsgespraeche:
+#@TODO Please fix German umlauts!
+ADMIN_ENTER_COUNTRY_CODE=Zweistelliger Laendercode:
+#@TODO Please fix German umlauts!
+ADMIN_ENTER_COUNTRY_CODE_EXAMPLE=(Beispiel: DE fuer Deutschland)
+#@TODO Please fix German umlauts!
+ADMIN_ENTER_COUNTRY_I18N_KEY=Schluessel fuer Sprachpaket:
+#@TODO Please fix German umlauts!
+ADMIN_SELECT_COUNTRY_IS_EXTERNAL_DIAL_PREFIX_REQUIORED=Wird der Praefix fuer lokale Gespraeche benoetigt? (Meistens ja)
+ADMIN_ENTER_COUNTRY_EXTERNAL_DIAL_PREFIX=Vorwahl fuer Gespraeche ausserhalb des Ortes: (meistens 0)
+#@TODO Please fix German umlauts!
+ADMIN_ENTER_COUNTRY_PHONE_CODE=Vorwahl fuer das Land:
+#@TODO Please fix German umlauts!
+ADMIN_ENTER_COUNTRY_PHONE_CODE_EXAMPLE=(Beispiel: 49 fuer Deutschland)
+#@TODO Please fix German umlauts!
+BUTTON_ADMIN_ADD_COUNTRY=Laenderdaten hinzufuegen
+ADMIN_LIST_COUNTRY_DATA_COUNTRY_ID=Id-Nummer:
+#@TODO Please fix German umlauts!
+ADMIN_LIST_COUNTRY_DATA_COUNTRY_CODE=Laendercode:
+ADMIN_LIST_COUNTRY_DATA_COUNTRY_EXTERNAL_DIAL_PREFIX=Vorwahl ausserorts:
+ADMIN_LIST_COUNTRY_DATA_COUNTRY_NAME=Land:
+#@TODO Please fix German umlauts!
+ADMIN_LINK_EDIT_DELETE_COUNTRY_TITLE=Aendern oder loeschen der Laenderdaten
+COUNTRY_GERMANY=Deutschland
index 2be98bfd3e3480c13bc059a72a6293fe664accc6..42060c924731a8919f3c6aecef98396a3723e4ed 100644 (file)
@@ -310,3 +310,29 @@ ADMIN_ADD_USER_PASSWORD_NOTICE=The password is being sent to the user's email ad
 ADMIN_ADD_USER_EMAIL_ADDRESS_NOTICE=*2: The email address must be unique.
 ADMIN_ADD_USER_CUSTOMER_NUMBER_NOTICE=A customer number is being automatically created on creation of the account.
 BUTTON_ADMIN_ADD_USER=Add new user account
+ADMIN_MENU_COUNTRY_TITLE=Country data
+LINK_ADMIN_LIST_COUNTRIES=List countries
+LINK_ADMIN_LIST_COUNTRIES_TITLE=List existing countries, add new country, edit and delete.
+PAGE_TITLE_ADMIN_LIST_COUNTRY=Manage country data
+CONTENT_TITLE_ADMIN_LIST_COUNTRY=Manage country data:
+ADMIN_ADD_COUNTRY_TITLE=Add new country
+ADMIN_COUNTRY_DATA_MINIMUM_NOTICE=Please fill out all fields.
+ADMIN_ADD_COUNTRY_I18N_KEY_NOTICE=The key for the language package must be in all upper-case and with underscores. Example: COUNTRY_USA for the U.S.A.
+ADMIN_ADD_COUNTRY_NOTICES=Notices for country data:
+ADMIN_COUNTRY_PHONE_DATA_LEGEND=Country data and phone:
+ADMIN_COUNTRY_PHONE_DATA_LEGEND_TITLE=Enter here data about the new country and data for phone numbers (example: dial prefix for abroad calls)
+ADMIN_ENTER_COUNTRY_ABROAD_DIAL_PREFIX=Dial prefix for abroad calls:
+ADMIN_ENTER_COUNTRY_CODE=2-letter country code:
+ADMIN_ENTER_COUNTRY_CODE_EXAMPLE=(Example: US for U.S.A.)
+ADMIN_ENTER_COUNTRY_I18N_KEY=Key for language package:
+ADMIN_SELECT_COUNTRY_IS_EXTERNAL_DIAL_PREFIX_REQUIORED=Is the local dial prefix required for local calls? (mostly yes)
+ADMIN_ENTER_COUNTRY_EXTERNAL_DIAL_PREFIX=Prefix for calls outside local city: (mostly 0)
+ADMIN_ENTER_COUNTRY_PHONE_CODE=Dial prefix for this country:
+ADMIN_ENTER_COUNTRY_PHONE_CODE_EXAMPLE=(Example: 1 for U.S.A.)
+BUTTON_ADMIN_ADD_COUNTRY=Add country data
+ADMIN_LIST_COUNTRY_DATA_COUNTRY_ID=Id number:
+ADMIN_LIST_COUNTRY_DATA_COUNTRY_CODE=Country code:
+ADMIN_LIST_COUNTRY_DATA_COUNTRY_EXTERNAL_DIAL_PREFIX=Dial prefix outside:
+ADMIN_LIST_COUNTRY_DATA_COUNTRY_NAME=Country:
+ADMIN_LINK_EDIT_DELETE_COUNTRY_TITLE=Edit or delete country
+COUNTRY_GERMANY=Germany
diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebApplicationBean.java b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebApplicationBean.java
new file mode 100644 (file)
index 0000000..e366374
--- /dev/null
@@ -0,0 +1,256 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.country;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import javax.enterprise.context.ApplicationScoped;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.jcountry.data.Country;
+import org.mxchange.jcountry.data.CountryData;
+import org.mxchange.jcountry.data.CountrySingletonBeanRemote;
+import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
+
+/**
+ * An administrative country bean
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("adminCountryController")
+@ApplicationScoped
+public class PizzaAdminCountryWebApplicationBean implements PizzaAdminCountryWebApplicationController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 18_598_175_719_603L;
+
+       /**
+        * Abroad dial prefix
+        */
+       private String countryAbroadDialPrefix;
+
+       /**
+        * Remote country EJB
+        */
+       private CountrySingletonBeanRemote countryBean;
+
+       /**
+        * 2-letter country code
+        */
+       private String countryCode;
+
+       /**
+        * Regular country controller
+        */
+       @Inject
+       private PizzaCountryWebApplicationController countryController;
+
+       /**
+        * Local dial prefix
+        */
+       private String countryExternalDialPrefix;
+
+       /**
+        * i18n bundle key
+        */
+       private String countryI18nKey;
+
+       /**
+        * Whether the local dial prefix is required to use
+        */
+       private Boolean countryIsLocalPrefixRequired;
+
+       /**
+        * Phone code
+        */
+       private Short countryPhoneCode;
+
+       /**
+        * Default constructor
+        */
+       public PizzaAdminCountryWebApplicationBean () {
+               // Try this
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup the bean
+                       this.countryBean = (CountrySingletonBeanRemote) context.lookup("java:global/PizzaService-ejb/country!org.mxchange.jcountry.data.CountrySingletonBeanRemote"); //NOI18N
+               } catch (final NamingException ex) {
+                       // Continue to throw
+                       throw new FaceletException(ex);
+               }
+       }
+
+       @Override
+       public void addCountry () {
+               // Create new country object
+               Country country = new CountryData();
+
+               // Add all data
+               country.setCountryAbroadDialPrefix(this.getCountryAbroadDialPrefix());
+               country.setCountryCode(this.getCountryCode());
+               country.setCountryExternalDialPrefix(this.getCountryExternalDialPrefix());
+               country.setCountryI18nkey(this.getCountryI18nKey());
+               country.setCountryIsLocalPrefixRequired(this.getCountryIsLocalPrefixRequired());
+               country.setCountryPhoneCode(this.getCountryPhoneCode());
+
+               // Does it already exist?
+               if (this.isCountryAdded(country)) {
+                       // Yes, then abort here
+                       throw new FaceletException(new CountryAlreadyAddedException(country));
+               }
+
+               try {
+                       // Send country to bean
+                       this.countryBean.addCountry(country);
+
+                       // Clear bean
+                       this.clear();
+               } catch (final CountryAlreadyAddedException ex) {
+                       // Throw again
+                       throw new FaceletException(ex);
+               }
+       }
+
+       @Override
+       public List<Country> allCountries () {
+               // Return "cached" version
+               return this.countryController.allCountries();
+       }
+
+       @Override
+       public String getCountryAbroadDialPrefix () {
+               return this.countryAbroadDialPrefix;
+       }
+
+       @Override
+       public void setCountryAbroadDialPrefix (final String countryAbroadDialPrefix) {
+               this.countryAbroadDialPrefix = countryAbroadDialPrefix;
+       }
+
+       @Override
+       public String getCountryCode () {
+               return this.countryCode;
+       }
+
+       @Override
+       public void setCountryCode (final String countryCode) {
+               this.countryCode = countryCode;
+       }
+
+       @Override
+       public String getCountryExternalDialPrefix () {
+               return this.countryExternalDialPrefix;
+       }
+
+       @Override
+       public void setCountryExternalDialPrefix (final String countryExternalDialPrefix) {
+               this.countryExternalDialPrefix = countryExternalDialPrefix;
+       }
+
+       @Override
+       public String getCountryI18nKey () {
+               return this.countryI18nKey;
+       }
+
+       @Override
+       public void setCountryI18nKey (final String countryI18nKey) {
+               this.countryI18nKey = countryI18nKey;
+       }
+
+       @Override
+       public Boolean getCountryIsLocalPrefixRequired () {
+               return this.countryIsLocalPrefixRequired;
+       }
+
+       @Override
+       public void setCountryIsLocalPrefixRequired (final Boolean countryIsLocalPrefixRequired) {
+               this.countryIsLocalPrefixRequired = countryIsLocalPrefixRequired;
+       }
+
+       @Override
+       public Short getCountryPhoneCode () {
+               return this.countryPhoneCode;
+       }
+
+       @Override
+       public void setCountryPhoneCode (final Short countryPhoneCode) {
+               this.countryPhoneCode = countryPhoneCode;
+       }
+
+       @Override
+       public boolean hasCountries () {
+               return (!this.allCountries().isEmpty());
+       }
+
+       /**
+        * Clears this bean
+        */
+       private void clear () {
+               // Clear all
+               this.setCountryAbroadDialPrefix(null);
+               this.setCountryCode(null);
+               this.setCountryExternalDialPrefix(null);
+               this.setCountryI18nKey(null);
+               this.setCountryIsLocalPrefixRequired(null);
+               this.setCountryPhoneCode(null);
+       }
+
+       /**
+        * Checks if given country is already added by iterating over the whole list
+        * and try to find it.
+        * <p>
+        * @param country Country instance to look for
+        * <p>
+        * @return Whether the country was already found
+        */
+       private boolean isCountryAdded (final Country country) {
+               // Default is not found
+               boolean isAdded = false;
+
+               // Now get whole ist
+               List<Country> countries = this.countryController.allCountries();
+
+               // Get iterator from it
+               Iterator<Country> iterator = countries.iterator();
+
+               // Check whole list
+               while (iterator.hasNext()) {
+                       // Get next country
+                       Country next = iterator.next();
+
+                       // Is country code or i18n the same?
+                       if ((Objects.equals(country.getCountryCode(), next.getCountryCode())) || (Objects.equals(country.getCountryI18nkey(), next.getCountryI18nkey()))) {
+                               // Yes, then abort search
+                               isAdded = true;
+                               break;
+                       }
+               }
+
+               // Return result
+               return isAdded;
+       }
+
+}
diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebApplicationController.java b/src/java/org/mxchange/pizzaapplication/beans/country/PizzaAdminCountryWebApplicationController.java
new file mode 100644 (file)
index 0000000..40b581e
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.pizzaapplication.beans.country;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jcountry.data.Country;
+
+/**
+ * An interface for administrative country beans
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public interface PizzaAdminCountryWebApplicationController extends Serializable {
+
+       /**
+        * A list of all countries
+        * <p>
+        * @return All countries
+        */
+       List<Country> allCountries ();
+
+       /**
+        * Adds country to all relevant beans and sends it to the EJB.
+        */
+       void addCountry ();
+
+       /**
+        * Checks whether countries has been registered
+        * <p>
+        * @return Whether countries has been registered
+        */
+       boolean hasCountries ();
+
+       /**
+        * Getter for abroad dial prefix
+        * <p>
+        * @return Abroad dial prefix
+        */
+       String getCountryAbroadDialPrefix ();
+
+       /**
+        * Setter for abroad dial prefix
+        * <p>
+        * @param countryAbroadDialPrefix Abroad dial prefix
+        */
+       void setCountryAbroadDialPrefix (final String countryAbroadDialPrefix);
+
+       /**
+        * Getter for 2-characters country code
+        * <p>
+        * @return Country code
+        */
+       String getCountryCode ();
+
+       /**
+        * Setter for 2-characters country code
+        * <p>
+        * @param countryCode Country code
+        */
+       void setCountryCode (final String countryCode);
+
+       /**
+        * Getter for i18n key for country name
+        * <p>
+        * @return i18n key for country name
+        */
+       String getCountryI18nKey ();
+
+       /**
+        * Setter for i18n key for country name
+        * <p>
+        * @param countryI18nKey i18n key for country name
+        */
+       void setCountryI18nKey (final String countryI18nKey);
+
+       /**
+        * Getter for whether the local dial prefix is required for local calls
+        * <p>
+        * @return Whether the local dial prefix is required
+        */
+       Boolean getCountryIsLocalPrefixRequired ();
+
+       /**
+        * Setter for whether the local dial prefix is required for local calls
+        * <p>
+        * @param countryIsLocalPrefixRequired Whether the local dial prefix is
+        *                                     required
+        */
+       void setCountryIsLocalPrefixRequired (final Boolean countryIsLocalPrefixRequired);
+
+       /**
+        * Getter for external dial prefix
+        * <p>
+        * @return External dial prefix
+        */
+       String getCountryExternalDialPrefix ();
+
+       /**
+        * Setter for external dial prefix
+        * <p>
+        * @param countryExternalDialPrefix External dial prefix
+        */
+       void setCountryExternalDialPrefix (final String countryExternalDialPrefix);
+
+       /**
+        * Getter for country code (example: 49 for Germany, 63 for Philippines)
+        * <p>
+        * @return Dial number without prefix
+        */
+       Short getCountryPhoneCode ();
+
+       /**
+        * Setter for country code (example: 49 for Germany, 63 for Philippines)
+        * <p>
+        * @param countryPhoneCode Country code
+        */
+       void setCountryPhoneCode (final Short countryPhoneCode);
+
+}
index a243051f94bf5300c3579565deeaa0729e6970ac..6cb876aff82a07acd40274c7c71edf63176126fd 100644 (file)
                        <from-outcome>admin_unlock_user</from-outcome>
                        <to-view-id>/admin/admin_user_unlock.xhtml</to-view-id>
                </navigation-case>
+               <navigation-case>
+                       <from-outcome>admin_add_user</from-outcome>
+                       <to-view-id>/admin/admin_user_add.xhtml</to-view-id>
+               </navigation-case>
+               <navigation-case>
+                       <from-outcome>admin_list_countries</from-outcome>
+                       <to-view-id>/admin/admin_country_list.xhtml</to-view-id>
+               </navigation-case>
        </navigation-rule>
        <navigation-rule>
                <from-view-id>/user/register.xhtml</from-view-id>
                        <to-view-id>/login/login_data_saved.xhtml</to-view-id>
                </navigation-case>
        </navigation-rule>
+       <navigation-rule>
+               <from-view-id>/admin/admin_country_list.xhtml</from-view-id>
+               <navigation-case>
+                       <from-outcome>admin_edit_country</from-outcome>
+                       <to-view-id>/admin/admin_country_edit.xhtml</to-view-id>
+               </navigation-case>
+       </navigation-rule>
 </faces-config>
diff --git a/web/WEB-INF/templates/admin/admin_form_country_data.tpl b/web/WEB-INF/templates/admin/admin_form_country_data.tpl
new file mode 100644 (file)
index 0000000..00f5142
--- /dev/null
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ui:composition
+       xmlns="http://www.w3.org/1999/xhtml"
+       xmlns:f="http://java.sun.com/jsf/core"
+       xmlns:h="http://java.sun.com/jsf/html"
+       xmlns:ui="http://java.sun.com/jsf/facelets">
+
+       <div class="para notice">
+               #{msg.ADMIN_COUNTRY_DATA_MINIMUM_NOTICE}
+       </div>
+
+       <div class="para">
+               <fieldset id="country_data">
+                       <legend title="#{msg.ADMIN_COUNTRY_PHONE_DATA_LEGEND_TITLE}">#{msg.ADMIN_COUNTRY_PHONE_DATA_LEGEND}</legend>
+
+                       <div class="table_row">
+                               <div class="table_left_medium">
+                                       <h:outputLabel for="countryAbroadDialPrefix" value="#{msg.ADMIN_ENTER_COUNTRY_ABROAD_DIAL_PREFIX}" />
+                               </div>
+
+                               <div class="table_right_medium">
+                                       <h:inputText class="input" id="countryAbroadDialPrefix" size="2" maxlength="10" value="#{adminCountryController.countryAbroadDialPrefix}" required="true">
+                                               <f:validateLongRange for="countryAbroadDialPrefix" minimum="0" maximum="99" />
+                                       </h:inputText>
+                               </div>
+
+                               <div class="clear"></div>
+                       </div>
+
+                       <div class="table_row">
+                               <div class="table_left_medium">
+                                       <h:outputLabel for="countryCode" value="#{msg.ADMIN_ENTER_COUNTRY_CODE}" />
+                               </div>
+
+                               <div class="table_right_medium">
+                                       <h:inputText class="input" id="countryCode" size="2" maxlength="2" value="#{adminCountryController.countryCode}" required="true">
+                                               <f:validateRegex for="countryCode" pattern="[A-Z]{2}" />
+                                       </h:inputText>
+
+                                       <h:outputText class="small notice" value="#{msg.ADMIN_ENTER_COUNTRY_CODE_EXAMPLE}" />
+                               </div>
+
+                               <div class="clear"></div>
+                       </div>
+
+                       <div class="table_row">
+                               <div class="table_left_medium">
+                                       <h:outputLabel for="countryI18nKey" value="#{msg.ADMIN_ENTER_COUNTRY_I18N_KEY}" />
+                               </div>
+
+                               <div class="table_right_medium">
+                                       <h:inputText class="input" id="countryI18nKey" size="20" maxlength="100" value="#{adminCountryController.countryI18nKey}" required="true">
+                                               <f:validateRegex for="countryI18nKey" pattern="[A-Z_]{2,}" />
+                                       </h:inputText>
+                               </div>
+
+                               <div class="clear"></div>
+                       </div>
+
+                       <div class="table_row">
+                               <div class="table_left_medium">
+                                       <h:outputLabel for="countryIsLocalPrefixRequired" value="#{msg.ADMIN_SELECT_COUNTRY_IS_EXTERNAL_DIAL_PREFIX_REQUIORED}" />
+                               </div>
+
+                               <div class="table_right_medium">
+                                       <h:selectOneListbox required="true" id="available" value="#{adminCountryController.countryIsLocalPrefixRequired}" size="1" class="select">
+                                               <f:selectItem itemValue="true" itemLabel="#{msg.YES}" />
+                                               <f:selectItem itemValue="false" itemLabel="#{msg.NO}" />
+                                       </h:selectOneListbox>
+                               </div>
+
+                               <div class="clear"></div>
+                       </div>
+
+                       <div class="table_row">
+                               <div class="table_left_medium">
+                                       <h:outputLabel for="countryExternalDialPrefix" value="#{msg.ADMIN_ENTER_COUNTRY_EXTERNAL_DIAL_PREFIX}" />
+                               </div>
+
+                               <div class="table_right_medium">
+                                       <h:inputText class="input" id="countryExternalDialPrefix" size="2" maxlength="10" value="#{adminCountryController.countryExternalDialPrefix}" required="true">
+                                               <f:validateLongRange for="countryAbroadDialPrefix" minimum="0" maximum="99" />
+                                       </h:inputText>
+                               </div>
+
+                               <div class="clear"></div>
+                       </div>
+
+                       <div class="table_row">
+                               <div class="table_left_medium">
+                                       <h:outputLabel for="countryPhoneCode" value="#{msg.ADMIN_ENTER_COUNTRY_PHONE_CODE}" />
+                               </div>
+
+                               <div class="table_right_medium">
+                                       <h:inputText class="input" id="countryPhoneCode" size="2" maxlength="6" value="#{adminCountryController.countryPhoneCode}" required="true">
+                                               <f:validateLongRange for="countryAbroadDialPrefix" minimum="0" maximum="99" />
+                                       </h:inputText>
+
+                                       <h:outputText class="small notice" value="#{msg.ADMIN_ENTER_COUNTRY_PHONE_CODE_EXAMPLE}" />
+                               </div>
+
+                               <div class="clear"></div>
+                       </div>
+               </fieldset>
+       </div>
+</ui:composition>
index 23eca94fba50bdf7866b02d0ea088ed3ada4e291..fad545df04b90a83aa88c695e7647dbcdb2c02b3 100644 (file)
                                </div>
 
                                <div class="table_right">
-                                       <h:selectOneMenu class="select" id="phoneCountryCode" value="#{adminUserController.phoneCountry}" converter="country">
+                                       <h:selectOneMenu class="select" id="countryPhoneCode" value="#{adminUserController.phoneCountry}" converter="country">
                                                <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
                                                <f:selectItems value="#{countryController.allCountries()}" var="c" itemValue="#{c}" itemLabel="#{c.countryAbroadDialPrefix}#{c.countryPhoneCode}" />
                                        </h:selectOneMenu>
                                <div class="table_right">
                                        <h:selectOneMenu class="select" id="cellphoneCarrier" value="#{adminUserController.cellphoneCarrier}" converter="CellphoneCarrierConverter">
                                                <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
-                                               <f:selectItems value="#{cellphone.allSmsProvider()}" var="p" itemValue="#{p}" itemLabel="#{p.providerCountry.countryLocalDialPrefix}#{p.providerDialPrefix} (#{p.providerName})" />
+                                               <f:selectItems value="#{cellphone.allSmsProvider()}" var="p" itemValue="#{p}" itemLabel="#{p.providerCountry.countryExternalDialPrefix}#{p.providerDialPrefix} (#{p.providerName})" />
                                        </h:selectOneMenu>
 
                                        <h:inputText class="input" id="cellphoneNumber" size="10" maxlength="20" value="#{adminUserController.cellphoneNumber}">
index b028c67380d913ad3ca8f0bf297ce81573c60a4c..0463ea64b35abcbd2a5c685b8e4760c8fde13839 100644 (file)
                                <li><h:link title="#{msg.LINK_ADMIN_UNLOCK_USER_TITLE}" outcome="admin_unlock_user" value="#{msg.LINK_ADMIN_UNLOCK_USER}" /></li>
                        </ul>
 
+                       <div class="menu_header">
+                               #{msg.ADMIN_MENU_COUNTRY_TITLE}
+                       </div>
+
+                       <ul>
+                               <li><h:link title="#{msg.LINK_ADMIN_LIST_COUNTRIES_TITLE}" outcome="admin_list_countries" value="#{msg.LINK_ADMIN_LIST_COUNTRIES}" /></li>
+                       </ul>
+
                        <div class="menu_header">
                                #{msg.ADMIN_MENU_LOGOUT_TITLE}
                        </div>
index cf574819ce3d7a2c5735451ebe8fa78d302a27f8..bb38e72f9041e094338d4d61df66af28efe3e62f 100644 (file)
                                </div>
 
                                <div class="table_right">
-                                       <h:selectOneMenu class="select" id="phoneCountryCode" value="#{userController.phoneCountry}" converter="country">
+                                       <h:selectOneMenu class="select" id="countryPhoneCode" value="#{userController.phoneCountry}" converter="country">
                                                <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
                                                <f:selectItems value="#{country.allCountries()}" var="c" itemValue="#{c}" itemLabel="#{c.countryAbroadDialPrefix}#{c.countryPhoneCode}" />
                                        </h:selectOneMenu>
                                <div class="table_right">
                                        <h:selectOneMenu class="select" id="cellphoneCarrier" value="#{userController.cellphoneCarrier}" converter="cellphoneCarrier">
                                                <f:selectItem itemValue="" itemLabel="#{msg.NONE_SELECTED}" />
-                                               <f:selectItems value="#{cellphone.allSmsProvider()}" var="p" itemValue="#{p}" itemLabel="#{p.providerCountry.countryLocalDialPrefix}#{p.providerDialPrefix} (#{p.providerName})" />
+                                               <f:selectItems value="#{cellphone.allSmsProvider()}" var="p" itemValue="#{p}" itemLabel="#{p.providerCountry.countryExternalDialPrefix}#{p.providerDialPrefix} (#{p.providerName})" />
                                        </h:selectOneMenu>
 
                                        <h:inputText class="input" id="cellphoneNumber" size="10" maxlength="20" value="#{userController.cellphoneNumber}">
diff --git a/web/admin/admin_country_delete.xhtml b/web/admin/admin_country_delete.xhtml
new file mode 100644 (file)
index 0000000..70c2234
--- /dev/null
@@ -0,0 +1,20 @@
+<?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 xmlns="http://www.w3.org/1999/xhtml"
+         xmlns:ui="http://java.sun.com/jsf/facelets"
+         xmlns:h="http://xmlns.jcp.org/jsf/html"
+         xmlns:f="http://xmlns.jcp.org/jsf/core"
+         >
+
+       <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
+               <ui:define name="admin_title">#{msg.PAGE_TITLE_ADMIN_DELETE_COUNTRY}</ui:define>
+
+               <ui:define name="content_header">
+                       #{msg.CONTENT_TITLE_ADMIN_DELETE_COUNTRY}
+               </ui:define>
+
+               <ui:define name="content">
+                       Here goes your content.
+               </ui:define>
+       </ui:composition>
+</html>
diff --git a/web/admin/admin_country_edit.xhtml b/web/admin/admin_country_edit.xhtml
new file mode 100644 (file)
index 0000000..0015790
--- /dev/null
@@ -0,0 +1,20 @@
+<?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 xmlns="http://www.w3.org/1999/xhtml"
+         xmlns:ui="http://java.sun.com/jsf/facelets"
+         xmlns:h="http://xmlns.jcp.org/jsf/html"
+         xmlns:f="http://xmlns.jcp.org/jsf/core"
+         >
+
+       <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
+               <ui:define name="admin_title">#{msg.PAGE_TITLE_ADMIN_EDIT_COUNTRY}</ui:define>
+
+               <ui:define name="content_header">
+                       #{msg.CONTENT_TITLE_ADMIN_EDIT_COUNTRY}
+               </ui:define>
+
+               <ui:define name="content">
+                       Here goes your content.
+               </ui:define>
+       </ui:composition>
+</html>
diff --git a/web/admin/admin_country_list.xhtml b/web/admin/admin_country_list.xhtml
new file mode 100644 (file)
index 0000000..c051c3d
--- /dev/null
@@ -0,0 +1,68 @@
+<?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 xmlns="http://www.w3.org/1999/xhtml"
+         xmlns:ui="http://java.sun.com/jsf/facelets"
+         xmlns:h="http://xmlns.jcp.org/jsf/html"
+         xmlns:f="http://xmlns.jcp.org/jsf/core"
+         >
+
+       <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
+               <ui:define name="admin_title">#{msg.PAGE_TITLE_ADMIN_LIST_COUNTRY}</ui:define>
+
+               <ui:define name="content_header">
+                       #{msg.CONTENT_TITLE_ADMIN_LIST_COUNTRY}
+               </ui:define>
+
+               <ui:define name="content">
+                       <h:dataTable id="table_list_countries" var="country" value="#{adminCountryController.allCountries()}" styleClass="table_medium" headerClass="table_header_column" summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_COUNTRIES}" rendered="#{adminCountryController.hasCountries()}">
+                               <h:column>
+                                       <f:facet name="header">#{msg.ADMIN_LIST_COUNTRY_DATA_COUNTRY_ID}</f:facet>
+
+                                       <h:link outcome="admin_edit_country" title="#{msg.ADMIN_LINK_EDIT_DELETE_COUNTRY_TITLE}" value="#{country.countryId}">
+                                               <f:param name="countryId" value="#{country.countryId}" />
+                                       </h:link>
+                               </h:column>
+
+                               <h:column>
+                                       <f:facet name="header">#{msg.ADMIN_LIST_COUNTRY_DATA_COUNTRY_CODE}</f:facet>
+
+                                       <h:outputText value="#{country.countryCode}" />
+                               </h:column>
+
+                               <h:column>
+                                       <f:facet name="header">#{msg.ADMIN_LIST_COUNTRY_DATA_COUNTRY_EXTERNAL_DIAL_PREFIX}</f:facet>
+
+                                       <h:outputText value="#{country.countryExternalDialPrefix}" />
+                               </h:column>
+
+                               <h:column>
+                                       <f:facet name="header">#{msg.ADMIN_LIST_COUNTRY_DATA_COUNTRY_NAME}</f:facet>
+
+                                       <h:outputText value="#{msg[country.countryI18nkey]}" />
+                               </h:column>
+                       </h:dataTable>
+
+                       <h:form id="add_country">
+                               <div class="table_medium">
+                                       <div class="table_header">
+                                               #{msg.ADMIN_ADD_COUNTRY_TITLE}
+                                       </div>
+
+                                       <ui:include src="/WEB-INF/templates/admin/admin_form_country_data.tpl" />
+
+                                       <div class="table_footer">
+                                               <h:commandButton class="reset" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
+                                               <h:commandButton class="submit" type="submit" id="register" value="#{msg.BUTTON_ADMIN_ADD_COUNTRY}" action="#{adminCountryController.addCountry()}" />
+                                       </div>
+                               </div>
+
+                               <div class="para notice">
+                                       #{msg.ADMIN_ADD_COUNTRY_NOTICES}
+                                       <ul>
+                                               <li>#{msg.ADMIN_ADD_COUNTRY_I18N_KEY_NOTICE}</li>
+                                       </ul>
+                               </div>
+                       </h:form>
+               </ui:define>
+       </ui:composition>
+</html>
index 22a6f9f4650eb8f58947ac46f1a36bfd26762233..dbc9c59dc214ade97eaf4c573affbb18ac99b4dd 100644 (file)
@@ -56,7 +56,7 @@ div, table {
        text-decoration : underline;
 }
 
-table, .table {
+table, .table, .table_medium {
        margin: 0px;
        padding: 0px;
 }
@@ -65,6 +65,10 @@ table, .table {
        width: 500px;
 }
 
+.table_medium {
+       width: 700px;
+}
+
 .table_big {
        width: 100%;
 }
@@ -98,6 +102,18 @@ table, .table {
        float: right;
 }
 
+.table_left_medium {
+       width: 300px;
+       min-height: 20px;
+       float: left;
+}
+
+.table_right_medium {
+       width: 250px;
+       min-height: 20px;
+       float: right;
+}
+
 .para {
        padding: 5px 5px 5px 5px;
 }