From: Roland Haeder Date: Mon, 14 Sep 2015 12:33:25 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f525a0998c47fd6e1fc28a184036e6a65d825fa8;p=pizzaservice-war.git Continued: - 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 --- diff --git a/lib/jshop-core.jar b/lib/jshop-core.jar index f7544741..88013336 100644 Binary files a/lib/jshop-core.jar and b/lib/jshop-core.jar differ diff --git a/src/java/org/mxchange/localization/bundle_de_DE.properties b/src/java/org/mxchange/localization/bundle_de_DE.properties index d9aecd41..6dc1198c 100644 --- a/src/java/org/mxchange/localization/bundle_de_DE.properties +++ b/src/java/org/mxchange/localization/bundle_de_DE.properties @@ -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. diff --git a/src/java/org/mxchange/localization/bundle_en_US.properties b/src/java/org/mxchange/localization/bundle_en_US.properties index 2080f6a7..aeb36b2d 100644 --- a/src/java/org/mxchange/localization/bundle_en_US.properties +++ b/src/java/org/mxchange/localization/bundle_en_US.properties @@ -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. diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebBean.java index 2fbd7726..51befd64 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebBean.java @@ -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; diff --git a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebController.java b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebController.java index 8d28a946..677c3c96 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/basket/BasketWebController.java @@ -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); } diff --git a/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java index 397f73b1..32841780 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/category/AdminCategoryWebBean.java @@ -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 diff --git a/src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebBean.java index d01efbc5..a0781c69 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/controller/ShopWebBean.java @@ -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 diff --git a/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java index d8d86e8e..9c4425a5 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/customer/CustomerWebBean.java @@ -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; diff --git a/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java index 335ed468..891cce60 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java @@ -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 diff --git a/web/WEB-INF/faces-config.xml b/web/WEB-INF/faces-config.xml index 44cbda7e..a699e4aa 100644 --- a/web/WEB-INF/faces-config.xml +++ b/web/WEB-INF/faces-config.xml @@ -61,16 +61,20 @@ admin_index /admin/index.xhtml - - basket - /basket.xhtml - + + basket + /basket.xhtml + + + item_not_changed + /errorHandler.xhtml + + + + /index.xhtml + + item_added + /item_added.xhtml + - - /index.xhtml - - item_added - /item_added.xhtml - - diff --git a/web/admin/product.xhtml b/web/admin/product.xhtml index 9e482ad3..e02c2784 100644 --- a/web/admin/product.xhtml +++ b/web/admin/product.xhtml @@ -31,7 +31,7 @@ - Einzelpreis: + #{msg.SINGLE_ITEM_PRICE} #{product.price} @@ -79,7 +79,7 @@
- Einzelpreis: + #{msg.SINGLE_ITEM_PRICE}
(z.B. 50.0)
diff --git a/web/basket.xhtml b/web/basket.xhtml index 845e9be6..d8860243 100644 --- a/web/basket.xhtml +++ b/web/basket.xhtml @@ -27,7 +27,7 @@ - Einzelpreis: + #{msg.SINGLE_ITEM_PRICE}
@@ -39,7 +39,7 @@ - Anzahl ändern: + #{msg.CHANGE_ITEM_AMOUNT} @@ -54,7 +54,7 @@ - Zwischensumme: + #{msg.TOTAL_ITEM_PRICE}
@@ -65,13 +65,13 @@
- Gesamtsumme: + #{msg.TOTAL_ORDER_PRICE}
- + diff --git a/web/index.xhtml b/web/index.xhtml index f682c0ea..14b879e5 100644 --- a/web/index.xhtml +++ b/web/index.xhtml @@ -11,20 +11,20 @@ //--> - Willkommen! + #{msg.PAGE_TITLE_INDEX_WELCOME} - Willkommen zum Pizza-Service + #{msg.SUB_TITLE_INDEX_WELCOME}
- Folgendes kann bestellt werden: + #{msg.FOLLOWING_PRODUCTS_ARE_AVAILABLE}
@@ -40,7 +40,7 @@
- +