From 15783dfb4e72e3afe2229d21e899f933643ffcb7 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 7 Aug 2015 11:56:20 +0200 Subject: [PATCH] Continued with project: MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - Included displaying of gender and translation (yes, there is a better way doing internalizations than this one) - Introduced BasePizzaServiceSystem which is a general class for (almost) all other classes - Moved some classes to proper location Signed-off-by:Roland Häder --- .../localization/bundle_de_DE.properties | 4 + .../localization/bundle_en_US.properties | 4 + .../BasePizzaServiceSystem.java | 28 ++ .../application/PizzaServiceApplication.java | 4 +- .../bean => beans}/CustomerBean.java | 18 +- .../bean/PizzaServiceCustomerBean.java | 248 ++++++++++++++++++ web/finished.jsp | 31 ++- web/order.jsp | 27 +- 8 files changed, 339 insertions(+), 25 deletions(-) create mode 100644 src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java rename src/java/org/mxchange/pizzaapplication/{customer/bean => beans}/CustomerBean.java (64%) create mode 100644 src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index 4b4c3c2d..f7de0503 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -12,3 +12,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . +BaseContact.gender.unknown.text=Unbekannt +BaseContact.gender.male.text=Herr +BaseContact.gender.female.text=Frau +BaseContact.gender.company.text=Firma diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 4b4c3c2d..0813997e 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -12,3 +12,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . +BaseContact.gender.unknown.text=Unknown +BaseContact.gender.male.text=Mr. +BaseContact.gender.female.text=Mrs. +BaseContact.gender.company.text=Company diff --git a/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java b/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java new file mode 100644 index 00000000..84f1e1c5 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/BasePizzaServiceSystem.java @@ -0,0 +1,28 @@ +/* + * 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 . + */ +package org.mxchange.pizzaapplication; + +import org.mxchange.jcore.BaseFrameworkSystem; + +/** + * A general class for whole pizza application. + * + * @author Roland Haeder + */ +public class BasePizzaServiceSystem extends BaseFrameworkSystem { + +} diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java index 8a6e4bf1..e856628a 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java @@ -25,7 +25,7 @@ import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; -import org.mxchange.jcore.BaseFrameworkSystem; +import org.mxchange.pizzaapplication.BasePizzaServiceSystem; import org.mxchange.pizzaapplication.product.PizzaProduct; import org.mxchange.pizzaapplication.product.Product; @@ -33,7 +33,7 @@ import org.mxchange.pizzaapplication.product.Product; * * @author Roland Haeder */ -public class PizzaServiceApplication extends BaseFrameworkSystem implements PizzaApplication { +public class PizzaServiceApplication extends BasePizzaServiceSystem implements PizzaApplication { /** * Main title */ diff --git a/src/java/org/mxchange/pizzaapplication/customer/bean/CustomerBean.java b/src/java/org/mxchange/pizzaapplication/beans/CustomerBean.java similarity index 64% rename from src/java/org/mxchange/pizzaapplication/customer/bean/CustomerBean.java rename to src/java/org/mxchange/pizzaapplication/beans/CustomerBean.java index e1edf34c..09023431 100644 --- a/src/java/org/mxchange/pizzaapplication/customer/bean/CustomerBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/CustomerBean.java @@ -14,26 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.mxchange.pizzaapplication.customer.bean; +package org.mxchange.pizzaapplication.beans; import org.mxchange.pizzaapplication.customer.Customer; -import org.mxchange.pizzaapplication.customer.PizzaServiceCustomer; /** - * A customer bean which hides the customer instance + * An interface for customer beans * * @author Roland Haeder */ -public class CustomerBean extends PizzaServiceCustomer implements Customer { - - /** - * Default constructor - */ - public CustomerBean () { - // Init customer instance - Customer customer = new PizzaServiceCustomer(); - - // Set it here - this.setContact(customer); - } +public interface CustomerBean extends Customer, Iterable { } diff --git a/src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java b/src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java new file mode 100644 index 00000000..88a6d3a8 --- /dev/null +++ b/src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java @@ -0,0 +1,248 @@ +/* + * 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 . + */ +package org.mxchange.pizzaapplication.customer.bean; + +import java.util.Iterator; +import org.mxchange.jcore.client.Client; +import org.mxchange.jcore.contact.Contact; +import org.mxchange.jcore.contact.Gender; +import org.mxchange.pizzaapplication.BasePizzaServiceSystem; +import org.mxchange.pizzaapplication.beans.CustomerBean; +import org.mxchange.pizzaapplication.customer.PizzaServiceCustomer; + +/** + * A customer bean which hides the customer instance + * + * @author Roland Haeder + */ +public class PizzaServiceCustomerBean extends BasePizzaServiceSystem implements CustomerBean { + /** + * Default constructor + */ + public PizzaServiceCustomerBean () { + // Instance customer + Contact customer = new PizzaServiceCustomer(); + + // Init bundle + this.initBundle(); + + // And set it here + this.setContact(customer); + } + + @Override + public String getBirthday () { + // Deligate to "hidden" object + return this.getContact().getBirthday(); + } + + @Override + public void setBirthday (final String birthday) { + // Deligate to "hidden" object + this.getContact().setBirthday(birthday); + } + + @Override + public String getCellphoneNumber () { + // Deligate to "hidden" object + return this.getContact().getCellphoneNumber(); + } + + @Override + public void setCellphoneNumber (final String cellphoneNumber) { + // Deligate to "hidden" object + this.getContact().setCellphoneNumber(cellphoneNumber); + } + + @Override + public String getCity () { + // Deligate to "hidden" object + return this.getContact().getCity(); + } + + @Override + public void setCity (final String city) { + // Deligate to "hidden" object + this.getContact().setCity(city); + } + + @Override + public String getComment () { + // Deligate to "hidden" object + return this.getContact().getComment(); + } + + @Override + public void setComment (final String comment) { + // Deligate to "hidden" object + this.getContact().setComment(comment); + } + + @Override + public String getCompanyName () { + // Deligate to "hidden" object + return this.getContact().getCompanyName(); + } + + @Override + public void setCompanyName (final String companyName) { + // Deligate to "hidden" object + this.getContact().setCompanyName(companyName); + } + + @Override + public String getCountryCode () { + // Deligate to "hidden" object + return this.getContact().getCountryCode(); + } + + @Override + public void setCountryCode (final String countryCode) { + // Deligate to "hidden" object + this.getContact().setCountryCode(countryCode); + } + + @Override + public String getEmailAddress () { + // Deligate to "hidden" object + return this.getContact().getEmailAddress(); + } + + @Override + public void setEmailAddress (final String emailAddress) { + // Deligate to "hidden" object + this.getContact().setEmailAddress(emailAddress); + } + + @Override + public String getFamilyName () { + // Deligate to "hidden" object + return this.getContact().getFamilyName(); + } + + @Override + public void setFamilyName (final String familyName) { + // Deligate to "hidden" object + this.getContact().setFamilyName(familyName); + } + + @Override + public String getFaxNumber () { + // Deligate to "hidden" object + return this.getContact().getFaxNumber(); + } + + @Override + public void setFaxNumber (final String faxNumber) { + // Deligate to "hidden" object + this.getContact().setFaxNumber(faxNumber); + } + + @Override + public Gender getGender () { + // Deligate to "hidden" object + return this.getContact().getGender(); + } + + @Override + public void setGender (final Gender gender) { + // Deligate to "hidden" object + this.getContact().setGender(gender); + } + + @Override + public long getHouseNumber () { + // Deligate to "hidden" object + return this.getContact().getHouseNumber(); + } + + @Override + public void setHouseNumber (final long houseNumber) { + // Deligate to "hidden" object + this.getContact().setHouseNumber(houseNumber); + } + + @Override + public String getPhoneNumber () { + // Deligate to "hidden" object + return this.getContact().getPhoneNumber(); + } + + @Override + public void setPhoneNumber (final String phoneNumber) { + // Deligate to "hidden" object + this.getContact().setPhoneNumber(phoneNumber); + } + + @Override + public String getStreet () { + // Deligate to "hidden" object + return this.getContact().getStreet(); + } + + @Override + public void setStreet (final String street) { + // Deligate to "hidden" object + this.getContact().setStreet(street); + } + + @Override + public String getSurname () { + // Deligate to "hidden" object + return this.getContact().getSurname(); + } + + @Override + public void setSurname (final String surname) { + // Deligate to "hidden" object + this.getContact().setSurname(surname); + } + + @Override + public String getTranslatedGender () { + // Deligate to "hidden" object + return this.getContact().getTranslatedGender(); + } + + @Override + public long getZipCode () { + // Deligate to "hidden" object + return this.getContact().getZipCode(); + } + + @Override + public void setZipCode (final long zipCode) { + // Deligate to "hidden" object + this.getContact().setZipCode(zipCode); + } + + @Override + public boolean isOwnContact () { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public Iterator iterator () { + // Deligate to "hidden" object + return this.getContact().iterator(); + } + + @Override + public void show (final Client client) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } +} diff --git a/web/finished.jsp b/web/finished.jsp index 61b604ba..6adaf51a 100644 --- a/web/finished.jsp +++ b/web/finished.jsp @@ -4,19 +4,17 @@ Author : Roland Haeder --%> -<%-- -<%@page errorPage="errorHandler.jsp" %> ---%> +<%--<%@page errorPage="errorHandler.jsp" %>--%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.util.Map"%> <%@page import="java.util.Iterator"%> <%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%> <%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%> -<%@page import="org.mxchange.pizzaapplication.customer.Customer" %> +<%@page import="org.mxchange.pizzaapplication.beans.CustomerBean" %> <%@page import="org.mxchange.pizzaapplication.product.Product"%> - + <% @@ -121,6 +119,29 @@ + + + Ihre Daten: + + + + + + <% + Iterator fieldIterator = customer.iterator(); + %> +
    + <% + while (fieldIterator.hasNext()) { + %> +
  • <%=fieldIterator.next()%>
  • + <% + } + %> +
+ + + <% diff --git a/web/order.jsp b/web/order.jsp index cc190c17..57b8786b 100644 --- a/web/order.jsp +++ b/web/order.jsp @@ -4,16 +4,18 @@ Author : Roland Haeder --%> -<%@page errorPage="errorHandler.jsp" %> +<%@page import="org.mxchange.jcore.contact.Gender"%> +<%--<%@page errorPage="errorHandler.jsp" %>--%> <%@page import="java.util.Iterator"%> <%@page import="java.util.Map"%> <%@page import="org.mxchange.pizzaapplication.product.Product"%> <%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%> <%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%> -<%@page import="org.mxchange.pizzaapplication.customer.Customer" %> +<%@page import="org.mxchange.pizzaapplication.beans.CustomerBean" %> <%@page contentType="text/html" pageEncoding="UTF-8"%> - + + <% @@ -127,6 +129,24 @@ Bitte Ihre Daten eingeben:
+
+ +
+
+ +
+
+
+
@@ -137,6 +157,7 @@
+
-- 2.39.5