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;
* @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
// Init products instance
this.products = new TreeMap<>();
+ // Init bundle
+ this.initBundle();
+
// Fill products list
this.fillProductsList();
}
// 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);
+ }
}
/**
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>
<%
}
%>