]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Some fixes
authorRoland Haeder <roland@mxchange.org>
Fri, 7 Aug 2015 11:28:08 +0000 (13:28 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 7 Aug 2015 11:28:08 +0000 (13:28 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/java/org/mxchange/pizzaapplication/application/PizzaServiceApplication.java
src/java/org/mxchange/pizzaapplication/customer/bean/PizzaServiceCustomerBean.java
web/order.jsp

index e856628a96f8435570873237b1cd9bdf95ff3064..da4e399166f97bb93e858c59d05181e91834fa27 100644 (file)
@@ -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<Object> it = customer.iterator();
+
+               // Output it
+               while (it.hasNext()) {
+                       Object field = it.next();
+                       this.getLogger().debug("field=" + field);
+               }
        }
 
        /**
index 88a6d3a8e16ffe804214b1bb08ced3697826d53d..931880a510d8f25b44f8ba7f92457b67df9bd4ae 100644 (file)
@@ -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);
        }
index 57b8786b16b5e519232af348fe354c34014b6346..77324721f5ca21618a1b78565f5383527ee274ad 100644 (file)
@@ -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"%>
                                                                                        <select name="gender" id="gender" size="1">
                                                                                                <%
                                                                                                Gender[] genders = Gender.values();
-                                                                                               for (Gender gender : genders) {
+                                                                                               for (final Gender gender : genders) {
                                                                                                        %>
-                                                                                                       <option value="<%=gender.getDatabaseValue()%>"><%=gender%></option>
+                                                                                                       <option value="<%=gender.name()%>"><%=gender%></option>
                                                                                                        <%
                                                                                                }
                                                                                                %>