]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Continued:
authorRoland Haeder <roland@mxchange.org>
Mon, 14 Sep 2015 12:33:25 +0000 (14:33 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 14 Sep 2015 12:33:25 +0000 (14:33 +0200)
- used interface Context as type
- internationalized more stuff (+ translates to English)
- added method changeItem() and finished it
- updated jar
Signed-off-by:Roland Häder <roland@mxchange.org>

14 files changed:
lib/jshop-core.jar
src/java/org/mxchange/localization/bundle_de_DE.properties
src/java/org/mxchange/localization/bundle_en_US.properties
src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebBean.java
src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebController.java
src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java
src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebBean.java
src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java
src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java
web/WEB-INF/faces-config.xml
web/admin/product.xhtml
web/basket.xhtml
web/index.xhtml
web/item_added.xhtml

index f75447419029685bf29ca755e42c0eb418e4501b..88013336b02c1d795fa399a67766638609d6b5a4 100644 (file)
Binary files a/lib/jshop-core.jar and b/lib/jshop-core.jar differ
index d9aecd411916ecbc772e1f21090611b67a0c78db..6dc1198c3898f69a7c99d2721a9dc2bf6124eb96 100644 (file)
@@ -34,3 +34,15 @@ INPUT_TITLE_ENTER_ITEM_AMOUNT=Geben Sie hier die Bestellmenge ein.
 NO_EMAIL_ADDRESS_ENTERED=Sie haben keine EMail-Adresse eingegeben.
 NO_PASSWORD_ENTERED=Sie haben kein Passwort eingegeben.
 ERROR_AMOUNT_IS_NOT_LONG=Die eingegebene Menge ist keine Zahl.
+PAGE_TITLE_INDEX_WELCOME=Willkommen!
+SUB_TITLE_INDEX_WELCOME=Willkommen zum Pizza-Service
+FOLLOWING_PRODUCT_ARE_AVAILABLE=Folgende Produkte k\u00f6nnen bestellt werden:
+SUBMIT_ADD_ITEM_TO_BASKET=Hinzuf\u00fcgen
+LINK_TITLE_TO_BASKET=Weiter zum Warenkorb.
+LINK_CHANGE_IN_BASKET=Im Warenkorb \u00e4ndern
+SINGLE_ITEM_PRICE=Einzelpreis:
+CHANGE_ITEM_AMOUNT=Bestellmenge \u00e4ndern:
+TOTAL_ITEM_PRICE=Zwischensumme:
+TOTAL_ORDER_PRICE=Gesamtsumme:
+NO_ITEMS_ADDED_TO_BASKET=Es befinden sich derzeit keine Artikel im Warenkorb.
+ITEM_NOT_ORDERED=Nicht bestellt.
index 2080f6a755353dbaa551e627b2512e2acfbe2f71..aeb36b2da5b977a2338ee8f352334a051b9bc5b3 100644 (file)
@@ -32,3 +32,15 @@ INPUT_TITLE_ENTER_ITEM_AMOUNT=Enter order amount here.
 NO_EMAIL_ADDRESS_ENTERED=You have entered no email address.
 NO_PASSWORD_ENTERED=You have entered no password.
 ERROR_AMOUNT_IS_NOT_LONG=The entered amount is not a number.
+PAGE_TITLE_INDEX_WELCOME=Welcome!
+SUB_TITLE_INDEX_WELCOME=Welcome to Pizza-Service
+FOLLOWING_PRODUCT_ARE_AVAILABLE=Following products can be ordered:
+SUBMIT_ADD_ITEM_TO_BASKET=Add
+LINK_TITLE_TO_BASKET=Continued to basket page.
+LINK_CHANGE_IN_BASKET=Change in basket
+SINGLE_ITEM_PRICE=Single price:
+CHANGE_ITEM_AMOUNT=Change ordered amount:
+TOTAL_ITEM_PRICE=Sub total:
+TOTAL_ORDER_PRICE=Gesamtsumme:
+NO_ITEMS_ADDED_TO_BASKET=There are no items in the basket.
+ITEM_NOT_ORDERED=Not ordered.
index 2fbd7726f96dc5347ea8042a55b81ea113941591..51befd64a552d2288c890da8a187bfe1b0282a6f 100644 (file)
@@ -21,6 +21,7 @@ import javax.annotation.PostConstruct;
 import javax.enterprise.context.SessionScoped;
 import javax.faces.FacesException;
 import javax.inject.Named;
+import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.jcoreee.beans.BaseFrameworkBean;
@@ -73,7 +74,7 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl
         */
        public BasketWebBean () throws NamingException {
                // Get initial context
-               InitialContext context = new InitialContext();
+               Context context = new InitialContext();
 
                // Get new application instance
                this.basket = new ShopBasket();
@@ -125,13 +126,13 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl
                // Is the current item/amount set?
                if (this.getCurrentItem() == null) {
                        // Current item is null
-                       throw new NullPointerException("currentItem is null");
+                       throw new NullPointerException("currentItem is null"); //NOI18N
                } else if (this.getCurrentItem().getProduct() == null) {
                        // Product is null
-                       throw new NullPointerException("currentItem.product is null");
+                       throw new NullPointerException("currentItem.product is null"); //NOI18N
                } else if (this.getCurrentItem().getAmount() == null) {
                        // Amount is null
-                       throw new NullPointerException("currentItem.amount is null");
+                       throw new NullPointerException("currentItem.amount is null"); //NOI18N
                }
 
                // Caculate item's price
@@ -143,8 +144,14 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl
 
        @Override
        public Float calculateItemPrice (final AddableBasketItem item) {
-               // Caculate item's price
-               Float totalPrice = (item.getProduct().getPrice() * item.getAmount());
+               // Default value
+               Float totalPrice = 0.0f;
+
+               // Is it a product?
+               if (item.isProductType()) {
+                       // Caculate item's price
+                       totalPrice = (item.getProduct().getPrice() * item.getAmount());
+               }
 
                // Return it
                return totalPrice;
@@ -168,6 +175,25 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl
                return totalPrice;
        }
 
+       @Override
+       public String changeItem (final AddableBasketItem item) {
+               // Default is not found
+               String targetPage = "item_not_changed"; //NOI18N
+
+               // Lookup item in basket
+               for (final AddableBasketItem basketItem : this.allItems()) {
+                       // Is it the same?
+                       if (basketItem.equals(item)) {
+                               // Found it, so allow redirect to proper page
+                               targetPage = "basket"; //NOI18N
+                               break;
+                       }
+               }
+
+               // Return page
+               return targetPage;
+       }
+
        @Override
        public Long getAmount () {
                return this.amount;
index 8d28a9463f7fecc7d1e415ab716672ac7e42bfa3..677c3c96533b7e12a36ad4dafb3cfc195d3663a3 100644 (file)
@@ -141,4 +141,13 @@ public interface BasketWebController extends Serializable {
         * @return Item amount of given product
         */
        public Long getItemAmount (final Product product);
+
+       /**
+        * Changes given item instance's amount in basket and redirects to proper
+        * page. If the item is not found, another "error" page is called.
+        *
+        * @param item Item instance to change
+        * @return Page redirection
+        */
+       public String changeItem (final AddableBasketItem item);
 }
index 397f73b13871ab2c5a21ec94f2503035f78f9f5e..3284178082e54ffaabcb2075b6f7be49e5679e5f 100644 (file)
@@ -20,6 +20,7 @@ import javax.enterprise.context.RequestScoped;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
+import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.jcoreee.beans.BaseFrameworkBean;
@@ -71,7 +72,7 @@ public class AdminCategoryWebBean extends BaseFrameworkBean implements AdminCate
         */
        public AdminCategoryWebBean () throws NamingException {
                // Get initial context
-               InitialContext context = new InitialContext();
+               Context context = new InitialContext();
 
                // Try to lookup the bean
                this.categoryBean = (AdminCategorySessionBeanRemote) context.lookup("ejb/stateless-admin-category"); //NOI18N
index d01efbc503910e1e49a5d6fe835bb0ad2c5b7deb..a0781c691ebb74d0d6d2dad1afb3db4332b910f2 100644 (file)
@@ -23,6 +23,7 @@ import javax.enterprise.context.ApplicationScoped;
 import javax.faces.FacesException;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Named;
+import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.jcoreee.beans.BaseFrameworkBean;
@@ -78,7 +79,7 @@ public class ShopWebBean extends BaseFrameworkBean implements ShopWebController
 
                try {
                        // Get initial context
-                       InitialContext context = new InitialContext();
+                       Context context = new InitialContext();
 
                        // Try to lookup the bean
                        CategorySessionBeanRemote categoryBean = (CategorySessionBeanRemote) context.lookup("ejb/stateless-category"); //NOI18N
index d8d86e8e0fd5640a676677f4c7b7147d7ac1a87b..9c4425a52090a8ad74d11df714df4ad98dece8be 100644 (file)
@@ -19,6 +19,7 @@ package org.mxchange.pizzaapplication.beans.customer;
 import javax.annotation.PostConstruct;
 import javax.enterprise.context.SessionScoped;
 import javax.inject.Named;
+import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.jcore.model.contact.gender.Gender;
@@ -120,7 +121,7 @@ public class CustomerWebBean extends BaseFrameworkBean implements CustomerWebCon
         */
        public CustomerWebBean () throws NamingException {
                // Get initial context
-               InitialContext context = new InitialContext();
+               Context context = new InitialContext();
 
                // Set gender to UNKNOWN
                this.gender = Gender.UNKNOWN;
index 335ed468700ecddf09fe629619de1393392005bd..891cce60fd745277009b468a7a6587fc57a00429 100644 (file)
@@ -21,6 +21,7 @@ import javax.enterprise.context.RequestScoped;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
+import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.jcoreee.beans.BaseFrameworkBean;
@@ -83,7 +84,7 @@ public class AdminProductWebBean extends BaseFrameworkBean implements AdminProdu
         */
        public AdminProductWebBean () throws NamingException {
                // Get initial context
-               InitialContext context = new InitialContext();
+               Context context = new InitialContext();
 
                // Try to lookup the bean
                this.productBean = (AdminProductSessionBeanRemote) context.lookup("ejb/stateless-admin-product"); //NOI18N
index 44cbda7ec6fd7f0debd3e9bd90be8965a3f4d49b..a699e4aa3923c10ea4f7ea819690d76509fcb57d 100644 (file)
                        <from-outcome>admin_index</from-outcome>
                        <to-view-id>/admin/index.xhtml</to-view-id>
                </navigation-case>
-           <navigation-case>
-               <from-outcome>basket</from-outcome>
-               <to-view-id>/basket.xhtml</to-view-id>
-           </navigation-case>
+               <navigation-case>
+                       <from-outcome>basket</from-outcome>
+                       <to-view-id>/basket.xhtml</to-view-id>
+               </navigation-case>
+               <navigation-case>
+                       <from-outcome>item_not_changed</from-outcome>
+                       <to-view-id>/errorHandler.xhtml</to-view-id>
+               </navigation-case>
+       </navigation-rule>
+       <navigation-rule>
+               <from-view-id>/index.xhtml</from-view-id>
+               <navigation-case>
+                       <from-outcome>item_added</from-outcome>
+                       <to-view-id>/item_added.xhtml</to-view-id>
+               </navigation-case>
        </navigation-rule>
-    <navigation-rule>
-        <from-view-id>/index.xhtml</from-view-id>
-        <navigation-case>
-            <from-outcome>item_added</from-outcome>
-            <to-view-id>/item_added.xhtml</to-view-id>
-        </navigation-case>
-    </navigation-rule>
 </faces-config>
index 9e482ad3339d9d14c6c7128746847c0e01cf9491..e02c27847315b9bac1d119f071742cd35723b594 100644 (file)
@@ -31,7 +31,7 @@
                                                </h:column>
 
                                                <h:column>
-                                                       <f:facet name="header">Einzelpreis:</f:facet>
+                                                       <f:facet name="header">#{msg.SINGLE_ITEM_PRICE}</f:facet>
                                                        #{product.price}
                                                </h:column>
 
@@ -79,7 +79,7 @@
 
                                                <div class="table_row">
                                                        <div class="table_left">
-                                                               Einzelpreis:
+                                                               #{msg.SINGLE_ITEM_PRICE}
                                                                <div class="tiny">(z.B. <em>50.0</em>)</div>
                                                        </div>
 
index 845e9be6f3f39f8287089bd936f0cae2b3ee8658..d8860243a52f651da1ef04378620d1ee2eba2929 100644 (file)
@@ -27,7 +27,7 @@
                                </h:column>
 
                                <h:column>
-                                       <f:facet name="header">Einzelpreis:</f:facet>
+                                       <f:facet name="header">#{msg.SINGLE_ITEM_PRICE}</f:facet>
 
                                        <div class="item_price">
                                                <ui:fragment rendered="#{item.isProductType()}">
@@ -39,7 +39,7 @@
                                </h:column>
 
                                <h:column>
-                                       <f:facet name="header">Anzahl ändern:</f:facet>
+                                       <f:facet name="header">#{msg.CHANGE_ITEM_AMOUNT}</f:facet>
 
                                        <h:form acceptcharset="utf-8" id="add_item">
                                                <h:commandButton class="submit" id="add" value="Ändern" action="#{basketController.changeItem(item)}" title="#{msg.BUTTON_TITLE_CHANGE_ITEM_AMOUNT}" />
@@ -54,7 +54,7 @@
                                </h:column>
 
                                <h:column>
-                                       <f:facet name="header">Zwischensumme:</f:facet>
+                                       <f:facet name="header">#{msg.TOTAL_ITEM_PRICE}</f:facet>
 
                                        <div class="item_total_price">
                                                <h:outputText class="price" id="item_price" value="#{basketController.calculateItemPrice(item)}" rendered="#{item.isProductType()}">
                        </h:dataTable>
 
                        <div class="totals_container">
-                               Gesamtsumme:
+                               #{msg.TOTAL_ORDER_PRICE}
                                <h:outputText class="price" id="total_sum" value="#{basketController.calculateTotalPrice()}">
                                        <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
                                </h:outputText>
                        </div>
 
-                       <h:outputText class="empty_basket" value="Es befinden sich derzeit keine Artikel im Warenkorb." rendered="#{basketController.isEmpty()}" />
+                       <h:outputText class="empty_basket" value="#{msg.NO_ITEMS_ADDED_TO_BASKET}" rendered="#{basketController.isEmpty()}" />
                </ui:define>
 
                <ui:define name="footer">
index f682c0ea2db54c3f116d956176d4bbe104321e94..14b879e503a7d4fc103c3eb1f76e19b712570666 100644 (file)
        //-->
 
        <ui:composition template="/WEB-INF/templates/guest/guest_base.tpl">
-               <ui:define name="title">Willkommen!</ui:define>
+               <ui:define name="title">#{msg.PAGE_TITLE_INDEX_WELCOME}</ui:define>
 
                <ui:define name="menu">
                        <ui:include id="menu" class="guest_menu" src="/WEB-INF/templates/guest/guest_menu.tpl" />
                </ui:define>
 
                <ui:define name="content_header">
-                       Willkommen zum Pizza-Service
+                       #{msg.SUB_TITLE_INDEX_WELCOME}
                </ui:define>
 
                <ui:define name="content">
                        <div class="table">
                                <div class="table_header">
-                                       Folgendes kann bestellt werden:
+                                       #{msg.FOLLOWING_PRODUCTS_ARE_AVAILABLE}
                                </div>
                        </div>
 
@@ -40,7 +40,7 @@
                                                                <div class="item_actions">
                                                                        <ui:fragment rendered="#{!basketController.isProductAdded(product)}">
                                                                                <h:form acceptcharset="utf-8" id="add_item">
-                                                                                       <h:commandButton class="submit" id="add" value="Hinzufügen" action="#{basketController.addItem(product)}" title="#{msg.BUTTON_TITLE_ADD_ITEM_TO_BASKET}" />
+                                                                                       <h:commandButton class="submit" id="add" value="#{msg.SUBMIT_ADD_ITEM_TO_BASKET}" action="#{basketController.addItem(product)}" title="#{msg.BUTTON_TITLE_ADD_ITEM_TO_BASKET}" />
 
                                                                                        <h:inputText class="input" id="amount" size="3" maxlength="20" value="#{basketController.amount}" title="#{msg.INPUT_TITLE_ENTER_ITEM_AMOUNT}">
                                                                                                <!--
@@ -58,7 +58,7 @@
                                                                                </div>
 
                                                                                <div class="item_basket_link">
-                                                                                       <h:link outcome="basket" title="Zum Warenkorb" value="Im Warenkorb ändern" />
+                                                                                       <h:link outcome="basket" title="#{msg.LINK_TITLE_TO_BASKET}" value="#{msg.LINK_CHANGE_IN_BASKET}" />
                                                                                </div>
 
                                                                                <div class="clear"></div>
 
                                                        <div class="table_right">
                                                                <div class="item_price">
-                                                                       Einzelpreis:
+                                                                       #{msg.SINGLE_ITEM_PRICE}
                                                                        <h:outputText class="price" value="#{product.price}">
                                                                                <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
                                                                        </h:outputText>
                                                                </div>
 
                                                                <div class="item_total_price">
-                                                                       Zwischensumme:
-                                                                       <h:outputText class="price" value="Nicht bestellt." rendered="#{!basketController.isProductAdded(product)}" />
+                                                                       #{msg.TOTAL_ITEM_PRICE}
+                                                                       <h:outputText class="price" value="#{msg.ITEM_NOT_ORDERED}" rendered="#{!basketController.isProductAdded(product)}" />
                                                                        <h:outputText class="price" value="#{basketController.calculateCurrentItemPrice()}" rendered="#{basketController.isProductAdded(product)}">
                                                                                <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
                                                                        </h:outputText>
@@ -90,7 +90,7 @@
                        </h:dataTable>
 
                        <div id="totals_container">
-                               Gesamtsumme:
+                               #{msg.TOTAL_ORDER_PRICE}
                                <h:outputText class="price" id="total_sum" value="#{basketController.calculateTotalPrice()}">
                                        <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
                                </h:outputText>
index a80b682649c0b90e7a8420cb6355d805c42b0d6f..216b4be2655cf83e2877dd814528d3941db111c2 100644 (file)
@@ -6,18 +6,18 @@
          >
 
        <ui:composition template="/WEB-INF/templates/guest/guest_base.tpl">
-               <ui:define name="guest_title">Produkt zum Warenkorb hinzugefuegt</ui:define>
+               <ui:define name="guest_title">Produkt zum Warenkorb hinzugefügt</ui:define>
 
                <ui:define name="menu">
                        <ui:include id="menu" class="guest_menu" src="/WEB-INF/templates/guest/guest_menu.tpl" />
                </ui:define>
 
                <ui:define name="content_header">
-                       Produkt zum Warenkorb hinzugefuegt
+                       Produkt zum Warenkorb hinzugefügt
                </ui:define>
 
                <ui:define name="content">
-                       Das Produkt wurde zum Warenkorb hinzugefuegt.
+                       Das Produkt wurde zum Warenkorb hinzugefügt.
                </ui:define>
 
                <ui:define name="footer">