}
// Init instance
- PizzaServiceApplication instance = null;
+ PizzaApplication instance = null;
- // Get instance from servlet
- Object object = application.getAttribute("service"); //NOI18N
+ // Get instance from servlet application (aka. "application scope")
+ Object object = application.getAttribute("app"); //NOI18N
// Is it set?
- if (object instanceof PizzaServiceApplication) {
+ if (object instanceof PizzaApplication) {
// Instance is set, so casting should work
- instance = (PizzaServiceApplication) object;
+ instance = (PizzaApplication) object;
} else if (object instanceof Object) {
// Not correct instance
- throw new ServletException("service is not set correctly"); //NOI18N
+ throw new ServletException("app is not set correctly"); //NOI18N
} else {
// "service" is null, so initialize it
instance = new PizzaServiceApplication();
// And set it here
- application.setAttribute("service", instance); //NOI18N
+ application.setAttribute("app", instance); //NOI18N
}
// Trace message
<%--<%@page errorPage="errorHandler.jsp" %>--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
-<%@page import="java.lang.reflect.Field"%>
-<%@page import="java.util.Map"%>
-<%@page import="java.util.Iterator"%>
-<%@page import="java.text.MessageFormat"%>
<%@page import="org.mxchange.pizzaapplication.beans.CustomerBean" %>
<%@page import="org.mxchange.pizzaapplication.application.PizzaServiceApplication"%>
<%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
-<jsp:useBean id="customer" scope="request" class="org.mxchange.pizzaapplication.customer.bean.PizzaServiceCustomerBean" type="CustomerBean" />
-<jsp:setProperty name="customer" property="*" />
-
<%
// Init application instance
PizzaApplication app = PizzaServiceApplication.getInstance(application);
// Is it post?
if ("POST".equals(request.getMethod())) { //NOI18N
- // Is POST, so continue with handling
- Iterator<Map.Entry<Field, Object>> fieldIterator = customer.iterator();
-
- while (fieldIterator.hasNext()) {
- // Get next field
- Map.Entry<Field, Object> entry = fieldIterator.next();
-
- // Debug message
- app.getLogger().debug(MessageFormat.format("entry {0}={1}", entry.getKey(), entry.getValue())); //NOI18N
-
- // Set it in session
- app.setValueInSession(session, entry.getKey().getName(), entry.getValue());
- }
-
// Redirect to proper URL
+ // @TODO Commented out for developing:
//response.sendRedirect(request.getContextPath() + "/finished.jsp");
- }
%>
+<jsp:useBean id="customer" scope="session" class="org.mxchange.pizzaapplication.customer.bean.PizzaServiceCustomerBean" type="CustomerBean" />
+<jsp:setProperty name="customer" property="*" />
<jsp:forward page="../finished.jsp" />
+<%
+ }
+%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="customer" scope="session" class="org.mxchange.pizzaapplication.customer.bean.PizzaServiceCustomerBean" type="CustomerBean" />
-
<jsp:setProperty name="customer" property="*" />
<%
<div class="data_left">
<label for="gender">Anrede</label>
</div>
+
<div class="data_right">
- <select name="gender" id="gender" size="1">
+ <select name="gender" id="gender" size="1" <%=app.getDisabledHtmlFromSession(request, session)%>>
<%
- Gender[] genders = Gender.values();
- for (final Gender gender : genders) {
+ // "Walk" through all genders and output them
+ for (final Gender gender : Gender.values()) {
%>
<option value="<%=gender.name()%>"<%
- synchronized (session) {
- // Get session value
- Object value = session.getAttribute("gender");
- if ((value instanceof Gender) && (value.equals(gender))) {
- // Output selected="selected"
- out.print("selected=\"selected\"");
- }
+ // Get gender from bean
+ Gender value= customer.getGender();
+
+ // Test it
+ if (value.equals(gender)) {
+ // Output selected="selected"
+ out.print("selected=\"selected\"");
}
%>><%=gender%></option>
<%
%>
</select>
</div>
- <div class="clear"></div>
+
+ <div class="clear"></div>
</div>
<div class="data_row">
<div class="data_left">
<label for="companyname">Firmenname:</label>
</div>
+
<div class="data_right">
- <input type="text" id="companyname" name="companyName" size="10" maxlength="255" value="<%=app.getPrintableValeFromSession(session, "companyname")%>" <%=app.getDisabledHtmlFromSession(request, session)%> />
+ <input type="text" id="companyname" name="companyName" size="15" maxlength="255" value="${customer.companyName}" <%=app.getDisabledHtmlFromSession(request, session)%> />
</div>
+
<div class="clear"></div>
</div>
<div class="data_left">
<label for="surname">Vorname:</label>
</div>
+
<div class="data_right">
- <input type="text" id="surname" name="surname" size="10" maxlength="255" value="<%=app.getPrintableValeFromSession(session, "surname")%>" <%=app.getDisabledHtmlFromSession(request, session)%> />
+ <input type="text" id="surname" name="surname" size="10" maxlength="255" value="${customer.surname}" <%=app.getDisabledHtmlFromSession(request, session)%> />
</div>
+
<div class="clear"></div>
</div>
<div class="data_left">
<label for="familyName">Nachname:</label>
</div>
+
<div class="data_right">
- <input type="text" id="familyName" name="familyName" size="10" maxlength="255" value="<%=app.getPrintableValeFromSession(session, "familyName")%>" <%=app.getDisabledHtmlFromSession(request, session)%> />
+ <input type="text" id="familyName" name="familyName" size="10" maxlength="255" value="${customer.familyName}" <%=app.getDisabledHtmlFromSession(request, session)%> />
</div>
+
<div class="clear"></div>
</div>
<div class="data_left">
<label for="street">Straße:</label>
</div>
+
<div class="data_right">
- <input type="text" id="street" name="street" size="20" maxlength="255" value="<%=app.getPrintableValeFromSession(session, "street")%>" <%=app.getDisabledHtmlFromSession(request, session)%> />
+ <input type="text" id="street" name="street" size="20" maxlength="255" value="${customer.street}" <%=app.getDisabledHtmlFromSession(request, session)%> />
</div>
+
<div class="clear"></div>
</div>
<div class="data_left">
<label for="houseNumber">Hausnummer:</label>
</div>
+
<div class="data_right">
- <input type="text" id="houseNumber" name="houseNumber" size="3" maxlength="5" value="<%=app.getPrintableValeFromSession(session, "houseNumber")%>" <%=app.getDisabledHtmlFromSession(request, session)%> />
+ <input type="text" id="houseNumber" name="houseNumber" size="3" maxlength="5" value="${customer.houseNumber}" <%=app.getDisabledHtmlFromSession(request, session)%> />
</div>
+
<div class="clear"></div>
</div>
<div class="data_left">
<label for="zipCode">Postleitzahl:</label>
</div>
+
<div class="data_right">
- <input type="text" id="zipCode" name="zipCode" size="5" maxlength="6" value="<%=app.getPrintableValeFromSession(session, "zipCode")%>" <%=app.getDisabledHtmlFromSession(request, session)%> />
+ <input type="text" id="zipCode" name="zipCode" size="5" maxlength="6" value="${customer.zipCode}" <%=app.getDisabledHtmlFromSession(request, session)%> />
</div>
+
<div class="clear"></div>
</div>
<div class="data_left">
<label for="city">Ort:</label>
</div>
+
<div class="data_right">
- <input type="text" id="city" name="city" size="10" maxlength="255" value="<%=app.getPrintableValeFromSession(session, "city")%>" <%=app.getDisabledHtmlFromSession(request, session)%> />
+ <input type="text" id="city" name="city" size="10" maxlength="255" value="${customer.city}" <%=app.getDisabledHtmlFromSession(request, session)%> />
</div>
+
<div class="clear"></div>
</div>
<div class="data_left">
<label for="phoneNumber">Telefon:</label>
</div>
+
<div class="data_right">
- <input type="text" id="phoneNumber" name="phoneNumber" size="20" maxlength="255" value="<%=app.getPrintableValeFromSession(session, "phoneNumber")%>" <%=app.getDisabledHtmlFromSession(request, session)%> />
+ <input type="text" id="phoneNumber" name="phoneNumber" size="20" maxlength="255" value="${customer.phoneNumber}" <%=app.getDisabledHtmlFromSession(request, session)%> />
</div>
+
<div class="clear"></div>
</div>
<div class="data_left">
<label for="faxNumber">Faxnummer:</label>
</div>
+
<div class="data_right">
- <input type="text" id="faxNumber" name="faxNumber" size="20" maxlength="255" value="<%=app.getPrintableValeFromSession(session, "faxNumber")%>" <%=app.getDisabledHtmlFromSession(request, session)%> />
+ <input type="text" id="faxNumber" name="faxNumber" size="20" maxlength="255" value="${customer.faxNumber}" <%=app.getDisabledHtmlFromSession(request, session)%> />
</div>
+
<div class="clear"></div>
</div>
<div class="data_left">
<label for="cellphoneNumber">Handy:</label>
</div>
+
<div class="data_right">
- <input type="text" id="cellphoneNumber" name="cellphoneNumber" size="20" maxlength="255" value="<%=app.getPrintableValeFromSession(session, "cellphoneNumber")%>" <%=app.getDisabledHtmlFromSession(request, session)%> />
+ <input type="text" id="cellphoneNumber" name="cellphoneNumber" size="20" maxlength="255" value="${customer.cellphoneNumber}" <%=app.getDisabledHtmlFromSession(request, session)%> />
</div>
+
<div class="clear"></div>
</div>
</fieldset>