From: Roland Haeder Date: Fri, 7 Aug 2015 11:28:08 +0000 (+0200) Subject: Some fixes X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6be180fefcc9c7661462e79e6e2e84d6236947c5;p=pizzaservice-war.git Some fixes Signed-off-by:Roland Häder --- diff --git a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java index e856628a..da4e3991 100644 --- a/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java +++ b/src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java @@ -25,7 +25,10 @@ import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; +import org.mxchange.jcore.contact.Gender; import org.mxchange.pizzaapplication.BasePizzaServiceSystem; +import org.mxchange.pizzaapplication.customer.Customer; +import org.mxchange.pizzaapplication.customer.PizzaServiceCustomer; import org.mxchange.pizzaapplication.product.PizzaProduct; import org.mxchange.pizzaapplication.product.Product; @@ -53,9 +56,7 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P * @throws javax.servlet.ServletException If object is not set correctly */ public static final PizzaApplication getInstance (final ServletContext application) throws ServletException { - // Trace message - new PizzaServiceApplication().getLogger().trace(MessageFormat.format("application={0} - CALLED!", application)); //NOI18N - + // Check application instance if (application == null) { // Not set throw new NullPointerException("application is null"); //NOI18N @@ -96,6 +97,9 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P // Init products instance this.products = new TreeMap<>(); + // Init bundle + this.initBundle(); + // Fill products list this.fillProductsList(); } @@ -304,6 +308,29 @@ public class PizzaServiceApplication extends BasePizzaServiceSystem implements P // Output data this.getLogger().debug(MessageFormat.format("Product {0}, {1}: {2}", product.getName(), product.getTitle(), product.getPrice())); //NOI18N } + + // Generate fake Customer instance + Customer customer = new PizzaServiceCustomer(); + + /* + * Need a least a gender :( See, that is why I don't like default + * constructors, you can easily miss something important and bam! You + * get an NPE. The fix here is, to have construtors (or factories) which + * requires all required instances that needs to be set to get a + * consitent object back. + */ + + // Gender is MALE now + customer.setGender(Gender.MALE); + + // Get iterator on all its fields + Iterator it = customer.iterator(); + + // Output it + while (it.hasNext()) { + Object field = it.next(); + this.getLogger().debug("field=" + field); + } } /** diff --git a/src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java b/src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java index 88a6d3a8..931880a5 100644 --- a/src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java +++ b/src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java @@ -37,9 +37,6 @@ public class PizzaServiceCustomerBean extends BasePizzaServiceSystem implements // Instance customer Contact customer = new PizzaServiceCustomer(); - // Init bundle - this.initBundle(); - // And set it here this.setContact(customer); } diff --git a/web/order.jsp b/web/order.jsp index 57b8786b..77324721 100644 --- a/web/order.jsp +++ b/web/order.jsp @@ -4,10 +4,10 @@ Author : Roland Haeder --%> -<%@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.jcore.contact.Gender"%> <%@page import="org.mxchange.pizzaapplication.product.Product"%> <%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%> <%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%> @@ -136,9 +136,9 @@