From 23f2f3f212597de8fb088dba2c4ec72d777eba96 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Mon, 12 Oct 2015 09:10:04 +0200 Subject: [PATCH] =?utf8?q?Continued:=20-=20added=20jcountry-core=20+=20jco?= =?utf8?q?untry-lib=20-=20added=20bean=20for=20country=20data=20retrieval?= =?utf8?q?=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/jcountry-lib.jar | Bin 0 -> 1284 bytes nbproject/build-impl.xml | 2 + nbproject/genfiles.properties | 4 +- nbproject/project.xml | 4 + .../beans/country/CountryWebBean.java | 82 ++++++++++++++++++ .../beans/country/CountryWebController.java | 36 ++++++++ .../templates/generic/form_personal_data.tpl | 14 +++ 7 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 lib/jcountry-lib.jar create mode 100644 src/java/org/mxchange/pizzaapplication/beans/country/CountryWebBean.java create mode 100644 src/java/org/mxchange/pizzaapplication/beans/country/CountryWebController.java diff --git a/lib/jcountry-lib.jar b/lib/jcountry-lib.jar new file mode 100644 index 0000000000000000000000000000000000000000..f917c1d8d53b77ff5af0d28950ce9c75cc374106 GIT binary patch literal 1284 zcmah|O>fgc5S>lZnwT0D6mj7|j;$beDn0@YLUKcbsw8cME3RncF78HKyIOA$<$%;5 z!ma;+8wW0M>aXaD8-Jl-BqYW_RBVy2X+Sa08(Es`nb^q6{VIw-4Of z?q0{ax&RoY&~1eNs03dEgzHhkkwW|K-fpMu9oYR&pN9NBi&gC{lQECN?dq0Yw@f#j zTX9dQf5fV|hCiR%k1ew$8CC4CwsWfS4ZHsCX`?o*Z&f$;CG`cXwjy~FNvcqB(=sh{ zR#pzQG=q-rb~foJ~!Ui9>7re~ENz+^Minwl?B#`L1G^jU`s)VZHituBDT zlmE+JvsD7?lllc-oU=b1F<%j=OqO`$cuaCC_$N9PY?T0k0*)dc3Mmn^_6mNj;#UC- zoT2}5RvvUop;BDl4~W88hu^M#r + @@ -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 @@

+
+
+ +
+ +
+ + + +
+ +
+
+
-- 2.39.5