From f525a0998c47fd6e1fc28a184036e6a65d825fa8 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Mon, 14 Sep 2015 14:33:25 +0200 Subject: [PATCH] =?utf8?q?Continued:=20-=20used=20interface=20Context=20as?= =?utf8?q?=20type=20-=20internationalized=20more=20stuff=20(+=20translates?= =?utf8?q?=20to=20English)=20-=20added=20method=20changeItem()=20and=20fin?= =?utf8?q?ished=20it=20-=20updated=20jar=20Signed-off-by:Roland=20H=C3=A4d?= =?utf8?q?er=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/jshop-core.jar | Bin 26658 -> 26726 bytes .../localization/bundle_de_DE.properties | 12 ++++++ .../localization/bundle_en_US.properties | 12 ++++++ .../beans/basket/BasketWebBean.java | 38 +++++++++++++++--- .../beans/basket/BasketWebController.java | 9 +++++ .../beans/category/AdminCategoryWebBean.java | 3 +- .../beans/controller/ShopWebBean.java | 3 +- .../beans/customer/CustomerWebBean.java | 3 +- .../beans/product/AdminProductWebBean.java | 3 +- web/WEB-INF/faces-config.xml | 26 +++++++----- web/admin/product.xhtml | 4 +- web/basket.xhtml | 10 ++--- web/index.xhtml | 18 ++++----- web/item_added.xhtml | 6 +-- 14 files changed, 107 insertions(+), 40 deletions(-) diff --git a/lib/jshop-core.jar b/lib/jshop-core.jar index f75447419029685bf29ca755e42c0eb418e4501b..88013336b02c1d795fa399a67766638609d6b5a4 100644 GIT binary patch delta 1115 zcmZ9KOH7kN5Xa}+wzQNI3i7IaAfSNdQA=BCsj-464bdPPf&^#_v^*rJ5j63H!3QQ7 zgD?>V6BCRH7vlvFY81ICJ|YJbjllyKPX?kU8a<#hTP5OQ_qY51@60#f?%Y~XJ}xMx zx_uh05x@X2)G}(aiVH2H?rVb93)wt>vC@p0ij#3oSkWFIw=M?9lydf7DHV(au{#Po zu6PW1Nf@JnKE_*7NtoHF$w7*!<5XXRl8RfJt0+ zZb7q}Zn1@X+xq*TuRfdw04HqHgQ|y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change/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 @@
- +