From: Roland Haeder Date: Mon, 12 Oct 2015 07:10:04 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=23f2f3f212597de8fb088dba2c4ec72d777eba96;p=pizzaservice-war.git Continued: - added jcountry-core + jcountry-lib - added bean for country data retrieval Signed-off-by:Roland Häder --- diff --git a/lib/jcountry-lib.jar b/lib/jcountry-lib.jar new file mode 100644 index 00000000..f917c1d8 Binary files /dev/null and b/lib/jcountry-lib.jar differ diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 1a6f7cb7..4bfee71f 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -1034,6 +1034,7 @@ exists or setup the property manually. For example like this: + @@ -1049,6 +1050,7 @@ exists or setup the property manually. For example like this: + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 502b5f11..38029533 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -3,6 +3,6 @@ build.xml.script.CRC32=82213886 build.xml.stylesheet.CRC32=651128d4@1.68.1.1 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=2f309951 -nbproject/build-impl.xml.script.CRC32=fc9d2f6b +nbproject/build-impl.xml.data.CRC32=3d4ee603 +nbproject/build-impl.xml.script.CRC32=1aff867f nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.68.1.1 diff --git a/nbproject/project.xml b/nbproject/project.xml index 078ef3c9..9d65d231 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -22,6 +22,10 @@ ${file.reference.jcountry-core.jar} WEB-INF/lib + + ${file.reference.jcountry-lib.jar} + WEB-INF/lib + ${file.reference.jphone-core.jar} WEB-INF/lib diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/CountryWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/country/CountryWebBean.java new file mode 100644 index 00000000..940a42ef --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/country/CountryWebBean.java @@ -0,0 +1,82 @@ +package org.mxchange.pizzaapplication.beans.country; + +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU 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 General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +import java.util.Collections; +import java.util.List; +import javax.annotation.PostConstruct; +import javax.enterprise.context.ApplicationScoped; +import javax.faces.view.facelets.FaceletException; +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.CountrySingletonBeanRemote; + +/** + * A country bean + *

+ * @author Roland Haeder + */ +@Named ("country") +@ApplicationScoped +public class CountryWebBean implements CountryWebController { + + /** + * Serial number + */ + private static final long serialVersionUID = 176_985_298_681_742_960L; + + /** + * Remote country EJB + */ + private final CountrySingletonBeanRemote countryBean; + + /** + * List of all countries + */ + private List countryList; + + /** + * Default constructor + */ + public CountryWebBean () { + // Try this + try { + // Get initial context + Context context = new InitialContext(); + + // Try to lookup the bean + this.countryBean = (CountrySingletonBeanRemote) context.lookup("ejb/addressbook-singleton-country"); //NOI18N + } catch (final NamingException ex) { + // Continue to throw + throw new FaceletException(ex); + } + } + + @Override + public List allCountries () { + // Return "cached" version + return Collections.unmodifiableList(this.countryList); + } + + @PostConstruct + public void init () { + this.countryList = this.countryBean.allCountries(); + } +} diff --git a/src/java/org/mxchange/pizzaapplication/beans/country/CountryWebController.java b/src/java/org/mxchange/pizzaapplication/beans/country/CountryWebController.java new file mode 100644 index 00000000..666fab67 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/beans/country/CountryWebController.java @@ -0,0 +1,36 @@ +package org.mxchange.pizzaapplication.beans.country; + +/* + * Copyright (C) 2015 Roland Haeder + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU 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 General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +import java.io.Serializable; +import java.util.List; +import org.mxchange.jcountry.data.Country; + +/** + * An interface for country beans + *

+ * @author Roland Haeder + */ +public interface CountryWebController extends Serializable { + + /** + * A list of all countries + *

+ * @return All countries + */ + public List allCountries (); +} diff --git a/web/WEB-INF/templates/generic/form_personal_data.tpl b/web/WEB-INF/templates/generic/form_personal_data.tpl index 35f7ae94..26da8c96 100644 --- a/web/WEB-INF/templates/generic/form_personal_data.tpl +++ b/web/WEB-INF/templates/generic/form_personal_data.tpl @@ -107,6 +107,20 @@

+
+
+ +
+ +
+ + + +
+ +
+
+