]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Continued with fixing:
authorRoland Haeder <roland@mxchange.org>
Fri, 11 Sep 2015 13:40:09 +0000 (15:40 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 11 Sep 2015 13:40:09 +0000 (15:40 +0200)
- add validator for amount
- some beans now have "cache" to save EJB calls and notify "controller" bean
- the gender bean does not need to get the genders from an EJB (saves a lot bandwidth)
- newly thrown exceptions added
- updated jars
Signed-off-by:Roland Häder <roland@mxchange.org>

18 files changed:
lib/jcoreee.jar
lib/jshop-core.jar
lib/jshop-ee-lib.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/controller/ShopWebController.java
src/java/org/mxchange/pizzaapplication/beans/gender/GenderWebBean.java
src/java/org/mxchange/pizzaapplication/beans/product/AdminProductWebBean.java
web/WEB-INF/faces-config.xml
web/WEB-INF/glassfish-web.xml
web/WEB-INF/templates/basket/mini_basket.tpl
web/WEB-INF/templates/guest/guest_base.tpl
web/WEB-INF/tlds/basket.tld
web/index.xhtml

index b2760ebae295cbad0437e4e512da91af8eca0b2c..893d1f9aad9b8ec2bf4607d123795b6547d7a940 100644 (file)
Binary files a/lib/jcoreee.jar and b/lib/jcoreee.jar differ
index d3ea1ca0994bd84f9efc0bb10e78f65e106694f5..93debb23d5481a5f36ded93af52324a612865006 100644 (file)
Binary files a/lib/jshop-core.jar and b/lib/jshop-core.jar differ
index ff8228177692e04aa42d48e83eaee3ff342a43c8..34f03eac5266bc772c35170ff88b0f27a631a267 100644 (file)
Binary files a/lib/jshop-ee-lib.jar and b/lib/jshop-ee-lib.jar differ
index ef91ec23931fad60b51572f9cb83f60e1fca0584..97e888d7d623ec2d23791376a56d80dd42b81b30 100644 (file)
@@ -28,4 +28,6 @@ YES=Ja
 NO=Nein
 PARENT_CATEGORY_CANNOT_BE_NULL=Elternkategorie darf nicht leer sein.
 CATEGORY_MUST_BE_SELECTED=Es muss eine Kategorie ausgewaehlt werden.
-ITEM_AMOUNT_IS_REQUIRED=Bestellmenge wird benoetigt.
+ERROR_AMOUNT_IS_NULL=Die Bestellmenge ist nicht gesetzt.
+BUTTON_TITLE_ADD_ITEM_TO_BASKET=F\u00fcgt das Produkt dem Warenkorb hinzu.
+INPUT_TITLE_ENTER_ITEM_AMOUNT=Geben Sie hier die Bestellmenge ein.
index 9554539c45a9540761117a192df62e1493c156e7..0b039d7e045798a5182b31bc6997f7003563efe8 100644 (file)
@@ -18,7 +18,7 @@ GENDER_FEMALE=Mrs.
 GENDER_COMPANY=Company
 MiniBasketTag.basket_is_empty=The basket is empty.
 MiniBasketTag.last_item=Last added item: {0}
-MiniBasketTag.additional_items=There are {0} items in the basket.
+MiniBasketTag.additional_items=There are {0} items in the basketController.
 MiniBasketTag.to_basket=To basket
 MiniBasketTag.header=Basket
 CATEGORY_HAS_NO_PARENT=No parent category
@@ -26,4 +26,6 @@ YES=Yes
 NO=No
 PARENT_CATEGORY_CANNOT_BE_NULL=Parent category cannot be empty.
 CATEGORY_MUST_BE_SELECTED=You have to select a category.
-ITEM_AMOUNT_IS_REQUIRED=Order amount is required.
+ERROR_AMOUNT_IS_NULL=Order amount is not set.
+BUTTON_TITLE_ADD_ITEM_TO_BASKET=Adds the product to the basket.
+INPUT_TITLE_ENTER_ITEM_AMOUNT=Enter order amount here.
index e3965945aadb237ae1b13f3cb578356b01b31ec6..89177ad398ad4bf09ee50e2d32227330bb245993 100644 (file)
@@ -16,6 +16,7 @@
  */
 package org.mxchange.pizzaapplication.beans.basket;
 
+import java.util.Map;
 import javax.annotation.PostConstruct;
 import javax.enterprise.context.SessionScoped;
 import javax.faces.FacesException;
@@ -25,7 +26,9 @@ import javax.naming.NamingException;
 import org.mxchange.jcoreee.beans.BaseFrameworkBean;
 import org.mxchange.jshopcore.exceptions.BasketItemAlreadyAddedException;
 import org.mxchange.jshopcore.model.basket.AddableBasketItem;
+import org.mxchange.jshopcore.model.basket.Basket;
 import org.mxchange.jshopcore.model.basket.BasketSessionBeanRemote;
+import org.mxchange.jshopcore.model.basket.ShopBasket;
 import org.mxchange.jshopcore.model.item.BasketItem;
 import org.mxchange.jshopcore.model.product.Product;
 
@@ -34,7 +37,7 @@ import org.mxchange.jshopcore.model.product.Product;
  *
  * @author Roland Haeder<roland@mxchange.org>
  */
-@Named ("basket")
+@Named ("basketController")
 @SessionScoped
 public class BasketWebBean extends BaseFrameworkBean implements BasketWebController {
 
@@ -44,14 +47,19 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl
        private static final long serialVersionUID = 5_476_347_320_198L;
 
        /**
-        * Basket bean
+        * Ordered amount
         */
-       private final BasketSessionBeanRemote basketBean;
+       private Long amount;
 
        /**
-        * Ordered amount
+        * Instance of wrapped basket
         */
-       private Long amount;
+       private final Basket<AddableBasketItem> basket;
+
+       /**
+        * Basket bean
+        */
+       private final BasketSessionBeanRemote basketBean;
 
        /**
         * Current item
@@ -67,10 +75,45 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl
                // Get initial context
                InitialContext context = new InitialContext();
 
+               // Get new application instance
+               this.basket = new ShopBasket();
+
                // Try to lookup
                this.basketBean = (BasketSessionBeanRemote) context.lookup("ejb/stateless-basket"); //NOI18N
        }
 
+       @Override
+       public String addItem (final Product product) {
+               // Generate item instance
+               AddableBasketItem item = new BasketItem(product, this.getAmount());
+               
+               // Is amount set?
+               if (this.getAmount() == null) {
+                       // No amount specified?!
+                       return null;
+               }
+               
+               try {
+                       // item should not be null
+                       if (null == item) {
+                               // Abort here
+                               throw new NullPointerException("item is null"); //NOI18N
+                       }
+                       
+                       // Deligate to model
+                       this.basket.addItem(item);
+                       
+                       // Remove amount
+                       this.setAmount(null);
+                       
+                       // Added
+                       return "item_added"; //NOI18N
+               } catch (final BasketItemAlreadyAddedException ex) {
+                       // Throw unchecked exception
+                       throw new FacesException(ex);
+               }
+       }
+
        @Override
        public Float calculateItemPrice () {
                // Is the current item/amount set?
@@ -96,31 +139,32 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl
        public Long getAmount () {
                return this.amount;
        }
-       
+
        @Override
        public void setAmount (final Long amount) {
                this.amount = amount;
        }
 
        @Override
-       public boolean isProductAdded (final Product product) {
-               // Must not be null
-               if (null == product) {
-                       // Abort here
-                       throw new NullPointerException("product is null"); //NOI18N
-               }
+       public AddableBasketItem getCurrentItem () {
+               return this.currentItem;
+       }
 
-               // Generate fake instance
-               AddableBasketItem item = new BasketItem(product);
+       @Override
+       public void setCurrentItem (final AddableBasketItem currentItem) {
+               this.currentItem = currentItem;
+       }
 
-               // Ask bean about it
-               return this.getBasketBean().isAdded(item);
+       @Override
+       public AddableBasketItem getLast () {
+               // Deligate to basket instance
+               return this.basket.getLast();
        }
 
        @Override
-       public boolean isEmpty () {
-               // Check local "cache"
-               return this.getBasketBean().isEmpty();
+       public int getLastNumRows () {
+               // Deligate to basket instance
+               return this.basket.getLastNumRows();
        }
 
        @Override
@@ -130,11 +174,44 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl
        }
 
        @PostConstruct
-       public void init () throws RuntimeException {
-               // Call super init first
+       public void init () {
+               // Call generic init first
                super.genericInit();
        }
 
+       @Override
+       public boolean isEmpty () {
+               // Deligate to basket instance
+               return this.basket.isEmpty();
+       }
+
+       @Override
+       public boolean isProductAdded (final Product product) {
+               // Must not be null
+               if (null == product) {
+                       // Abort here
+                       throw new NullPointerException("product is null"); //NOI18N
+               }
+
+               // Generate fake instance
+               AddableBasketItem fake = new BasketItem(product);
+
+               // Ask bean about it
+               boolean isAdded = this.basket.isAdded(fake);
+
+               // Is it added?
+               if (isAdded) {
+                       // Get item
+                       AddableBasketItem item = this.getItemFromProduct(product);
+
+                       // Set this as current item
+                       this.setCurrentItem(item);
+               }
+
+               // Return status
+               return isAdded;
+       }
+
        /**
         * Getter for basket bean instance
         *
@@ -144,45 +221,50 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl
                return this.basketBean;
        }
 
-       @Override
-       public String addItem (final Product product) {
-               // Generate item instance
-               AddableBasketItem item = new BasketItem(product);
-
-               // Is amount set?
-               if (this.getAmount() == null) {
-                       // No amount specified?!
-                       return null;
+       /**
+        * Somewhat getter for an item instance from given product instance. This
+        * method returns null if no item was found to given product. The product is
+        * found by checking it's id and itemType=product
+        *
+        * @param product Product instance
+        * @return Item instance or null if not found
+        */
+       private AddableBasketItem getItemFromProduct (final Product product) {
+               // Product must not be null
+               if (null == product) {
+                       // Abort here
+                       throw new NullPointerException("product is null"); //NOI18N
                }
 
-               // Set amount
-               item.setAmount(this.getAmount());
+               // Create item instance
+               AddableBasketItem foundItem = null;
 
-               try {
-                       // Handle it to bean
-                       this.getBasketBean().addItem(item);
+               // Create fake instance
+               AddableBasketItem fake = new BasketItem(product);
 
-                       // Add item to local basket, too
-                       //this.basket.addItem(item);
+               // Get all items
+               Map<Long, AddableBasketItem> map = this.basket.getAll();
 
-                       // Remove amount
-                       this.setAmount(null);
+               // Check all entries
+               for (Map.Entry<Long, AddableBasketItem> entrySet : map.entrySet()) {
+                       // Get item
+                       AddableBasketItem item = entrySet.getValue();
 
-                       // Added
-                       return "item_added"; //NOI18N
-               } catch (final BasketItemAlreadyAddedException ex) {
-                       // Throw unchecked exception
-                       throw new FacesException(ex);
-               }
-       }
+                       // item must not be null
+                       if (null == item) {
+                               // Abort here
+                               throw new NullPointerException("item is null"); //NOI18N
+                       }
 
-       @Override
-       public AddableBasketItem getCurrentItem () {
-               return this.currentItem;
-       }
+                       // Is it the same?
+                       if (item.equals(fake)) {
+                               // Set found item and abort look
+                               foundItem = item;
+                               break;
+                       }
+               }
 
-       @Override
-       public void setCurrentItem (final AddableBasketItem currentItem) {
-               this.currentItem = currentItem;
+               // Return it
+               return foundItem;
        }
 }
index d071350686884d554a2963f252969c6a46e81d6a..ad81ef88dcf318cf0299eaaf84d898a2c3120930 100644 (file)
@@ -94,4 +94,18 @@ public interface BasketWebController extends Serializable {
         * @return Current item's total price
         */
        public Float calculateItemPrice ();
+
+       /**
+        * Getter for last entry
+        *
+        * @return Last added item in basket
+        */
+       public AddableBasketItem getLast ();
+
+       /**
+        * Getter for last num rows
+        *
+        * @return Last num rows
+        */
+       public int getLastNumRows ();
 }
index 2be39da7f0bf2e84d98aca26305ab009bcf8abb3..0f73f9b4b3d8dbf98ec5f4144885a84f32376fb3 100644 (file)
@@ -18,6 +18,7 @@ package org.mxchange.pizzaapplication.beans.category;
 
 import javax.enterprise.context.RequestScoped;
 import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
 import javax.inject.Named;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
@@ -26,6 +27,7 @@ import org.mxchange.jshopcore.exceptions.CategoryTitleAlreadyUsedException;
 import org.mxchange.jshopcore.model.category.Category;
 import org.mxchange.jshopcore.model.category.CategorySessionBeanRemote;
 import org.mxchange.jshopcore.model.category.ProductCategory;
+import org.mxchange.pizzaapplication.beans.controller.ShopWebController;
 
 /**
  * Main application class
@@ -36,7 +38,7 @@ import org.mxchange.jshopcore.model.category.ProductCategory;
 @RequestScoped
 public class AdminCategoryWebBean extends BaseFrameworkBean implements AdminCategoryWebController {
        /**
-        * Serial id
+        * Serial number
         */
        private static final long serialVersionUID = 5_819_375_183_472_871L;
 
@@ -45,6 +47,12 @@ public class AdminCategoryWebBean extends BaseFrameworkBean implements AdminCate
         */
        private final CategorySessionBeanRemote categoryBean;
 
+       /**
+        * Shop bean
+        */
+       @Inject
+       private ShopWebController controller;
+
        /**
         * Category title
         */
@@ -76,8 +84,11 @@ public class AdminCategoryWebBean extends BaseFrameworkBean implements AdminCate
                        category.setParentId(this.getParentId());
                        category.setTitle(this.getTitle());
 
-                       // Deligate to bean
+                       // Deligate to remote bean
                        this.categoryBean.doAdminAddCategory(category);
+
+                       // Also send it to the controller bean
+                       this.controller.addCategory(category);
                } catch (final CategoryTitleAlreadyUsedException ex) {
                        // Continue to throw
                        throw new FaceletException(ex);
index 32eb722f3d496be3e15d924262608c389b7de87d..d01efbc503910e1e49a5d6fe835bb0ad2c5b7deb 100644 (file)
@@ -19,7 +19,7 @@ package org.mxchange.pizzaapplication.beans.controller;
 import java.util.Deque;
 import java.util.Queue;
 import javax.annotation.PostConstruct;
-import javax.enterprise.context.SessionScoped;
+import javax.enterprise.context.ApplicationScoped;
 import javax.faces.FacesException;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Named;
@@ -38,47 +38,70 @@ import org.mxchange.jshopcore.model.product.ProductSessionBeanRemote;
  * @author Roland Haeder<roland@mxchange.org>
  */
 @Named("controller")
-@SessionScoped
+@ApplicationScoped
 public class ShopWebBean extends BaseFrameworkBean implements ShopWebController {
 
        /**
-        * Serial id
+        * Serial number
         */
        private static final long serialVersionUID = 58_137_539_530_279L;
 
        /**
-        * Remote bean for categories
+        * "Cache" for all available products
         */
-       private final CategorySessionBeanRemote categoryBean;
+       private Deque<Product> availableProducts;
 
        /**
-        * Remote bean for products
+        * All categories
         */
-       private final ProductSessionBeanRemote productBean;
+       private Deque<Category> categories;
 
-       /**
-        * Default constructor
-        *
-        * @throws javax.naming.NamingException Something happened here?
-        */
-       public ShopWebBean () throws NamingException {
-               // Get initial context
-               InitialContext context = new InitialContext();
+       @Override
+       public void addCategory (final Category category) {
+               // Add the category
+               this.categories.add(category);
+       }
+
+       @Override
+       public void addProduct (final Product product) {
+               // Is the product available?
+               if (product.getAvailable()) {
+                       // Add it
+                       this.availableProducts.add(product);
+               }
+       }
+
+       @PostConstruct
+       public void init () {
+               // Call super init for getting resource bundle
+               super.genericInit();
 
-               // Try to lookup the bean
-               this.categoryBean = (CategorySessionBeanRemote) context.lookup("ejb/stateless-category"); //NOI18N
+               try {
+                       // Get initial context
+                       InitialContext context = new InitialContext();
 
-               // Try to lookup the bean
-               this.productBean = (ProductSessionBeanRemote) context.lookup("ejb/stateless-product"); //NOI18N
+                       // Try to lookup the bean
+                       CategorySessionBeanRemote categoryBean = (CategorySessionBeanRemote) context.lookup("ejb/stateless-category"); //NOI18N
+
+                       // Get all categories
+                       this.categories = categoryBean.getAllCategories();
+
+                       // Try to lookup the bean
+                       ProductSessionBeanRemote productBean = (ProductSessionBeanRemote) context.lookup("ejb/stateless-product"); //NOI18N
+
+                       // Get available products list
+                       this.availableProducts = productBean.getAvailableProducts();
+               } catch (final NamingException e) {
+                       // Continued to throw
+                       throw new FacesException(e);
+               }
        }
 
        @Override
        public Deque<Category> getAllCategories () throws FacesException {
-               // Get List back
-               Deque<Category> deque = this.getCategoryBean().getAllCategories();
-
                // Return it
-               return deque;
+               // TODO Find something better here to prevent warning
+               return this.categories;
        }
 
        @Override
@@ -98,34 +121,8 @@ public class ShopWebBean extends BaseFrameworkBean implements ShopWebController
 
        @Override
        public Queue<Product> getAvailableProducts () throws FacesException {
-               // Get queue from bean
-               Queue<Product> queue = this.getProductBean().getAvailableProducts();
-
                // Return it
-               return queue;
-       }
-
-       @PostConstruct
-       public void init () {
-               // Call super init for getting resource bundle
-               super.genericInit();
-       }
-
-       /**
-        * Getter for shop remote bean
-        *
-        * @return Remote shop bean
-        */
-       private CategorySessionBeanRemote getCategoryBean () {
-               return this.categoryBean;
-       }
-
-       /**
-        * Getter for shop remote bean
-        *
-        * @return Remote shop bean
-        */
-       private ProductSessionBeanRemote getProductBean () {
-               return this.productBean;
+               // TODO Find something better here to prevent warning
+               return this.availableProducts;
        }
 }
index 547c66e99396c98c5d8c962757589bd9f7da5ff8..88e0b1c33e4f9a1c8a4d7014ebcba78ff3362731 100644 (file)
@@ -30,6 +30,20 @@ import org.mxchange.jshopcore.model.product.Product;
  */
 public interface ShopWebController extends Serializable {
 
+       /**
+        * Adds given category to the "cached" instance
+        *
+        * @param category Category instance
+        */
+       public void addCategory (final Category category);
+
+       /**
+        * Adds given product to the "cached" instance
+        *
+        * @param product Product instance
+        */
+       public void addProduct (final Product product);
+
        /**
         * Some "getter" for a linked list of only available products
         * 
index e15647c00f6360986cff49c7f1b2ec76280944ca..c93c3995068f83c7b16cbc496a223e15031576fc 100644 (file)
@@ -19,10 +19,8 @@ package org.mxchange.pizzaapplication.beans.gender;
 import java.util.List;
 import javax.enterprise.context.ApplicationScoped;
 import javax.inject.Named;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 import org.mxchange.jcore.model.contact.gender.Gender;
-import org.mxchange.jcore.model.contact.gender.GenderSessionBeanRemote;
+import org.mxchange.jcore.model.contact.gender.GenderUtils;
 import org.mxchange.jcoreee.beans.BaseFrameworkBean;
 
 /**
@@ -39,46 +37,25 @@ public class GenderWebBean extends BaseFrameworkBean implements GenderWebControl
         */
        private static final long serialVersionUID = 835_482_364_189L;
 
-       /**
-        * Remote bean
-        */
-       private final GenderSessionBeanRemote genderBean;
-
        /**
         * Default constructor
-        * 
-        * @throws javax.naming.NamingException If something happens?
         */
-       public GenderWebBean () throws NamingException {
-               // Get initial context
-               InitialContext context = new InitialContext();
-
-               // Try to lookup bean
-               this.genderBean = (GenderSessionBeanRemote) context.lookup("ejb/stateful-gender"); //NOI18N
+       public GenderWebBean () {
        }
 
        @Override
        public Gender[] getAllGenders () {
                // Return it
-               return this.getGenderBean().allGenders();
+               return Gender.values();
        }
 
        @Override
        public List<Gender> getSelectableGenders () {
                // Init array
                // TODO Call EJB here?
-               List<Gender> genders = this.getGenderBean().selectableGenders();
+               List<Gender> genders = GenderUtils.selectableGenders();
 
                // Return it
                return genders;
        }
-
-       /**
-        * Getter for data remote bean
-        *
-        * @return data remote bean
-        */
-       private GenderSessionBeanRemote getGenderBean () {
-               return this.genderBean;
-       }
 }
index 1e098fd382bdb69a1e5427e01e37463055e2c6d0..c37417d877f3745f78f937100bc06e46410e009f 100644 (file)
@@ -19,14 +19,17 @@ package org.mxchange.pizzaapplication.beans.product;
 import java.util.Deque;
 import javax.enterprise.context.RequestScoped;
 import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
 import javax.inject.Named;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.jcoreee.beans.BaseFrameworkBean;
+import org.mxchange.jshopcore.exceptions.CannotAddProductException;
 import org.mxchange.jshopcore.exceptions.ProductTitleAlreadyUsedException;
 import org.mxchange.jshopcore.model.product.GenericProduct;
 import org.mxchange.jshopcore.model.product.Product;
 import org.mxchange.jshopcore.model.product.ProductSessionBeanRemote;
+import org.mxchange.pizzaapplication.beans.controller.ShopWebController;
 
 /**
  * Main application class
@@ -38,7 +41,7 @@ import org.mxchange.jshopcore.model.product.ProductSessionBeanRemote;
 public class AdminProductWebBean extends BaseFrameworkBean implements AdminProductWebController {
 
        /**
-        * Serial id
+        * Serial number
         */
        private static final long serialVersionUID = 5_819_375_183_472_871L;
        
@@ -63,6 +66,12 @@ public class AdminProductWebBean extends BaseFrameworkBean implements AdminProdu
         */
        private final ProductSessionBeanRemote productBean;
 
+       /**
+        * Shop bean
+        */
+       @Inject
+       private ShopWebController controller;
+
        /**
         * Property title
         */
@@ -96,12 +105,15 @@ public class AdminProductWebBean extends BaseFrameworkBean implements AdminProdu
                        // Call bean
                        this.productBean.doAdminAddProduct(product);
 
+                       // Add to shop controller
+                       this.controller.addProduct(product);
+
                        // Set all to null
                        this.setAvailable(Boolean.FALSE);
                        this.setId(null);
                        this.setPrice(null);
                        this.setTitle(null);
-               } catch (final ProductTitleAlreadyUsedException ex) {
+               } catch (final ProductTitleAlreadyUsedException | CannotAddProductException ex) {
                        // Continue to throw
                        throw new FaceletException(ex);
                }
index 4a8b5573aa48e399a1ad1a41431b512b58abb194..46fa57203ce1768483ba30ac9bae835aa75a2728 100644 (file)
                <validator-id>NameValidator</validator-id>
                <validator-class>org.mxchange.jcoreee.validator.string.names.NameValidator</validator-class>
        </validator>
+       <validator>
+               <validator-id>ItemAmountValidator</validator-id>
+               <validator-class>org.mxchange.jcoreee.validator.number.item_amount.ItemAmountValidator</validator-class>
+       </validator>
        <navigation-rule>
                <from-view-id>*</from-view-id>
                <navigation-case>
@@ -59,7 +63,7 @@
                </navigation-case>
            <navigation-case>
                <from-outcome>basket</from-outcome>
-               <to-view-id>/basket.xhtml</to-view-id>
+               <to-view-id>/basketController.xhtml</to-view-id>
            </navigation-case>
        </navigation-rule>
     <navigation-rule>
index 730d5867ab0ae94187f915a8951b486dde8bc841..eaf6448782180e7459a4c76bad9123336afbc847 100644 (file)
@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
 <glassfish-web-app error-url="">
-  <context-root>/PizzaService-war</context-root>
-  <class-loader delegate="true"/>
-  <jsp-config>
-    <property name="keepgenerated" value="true">
-      <description>Keep a copy of the generated servlet class' java code.</description>
-    </property>
-  </jsp-config>
+       <context-root>/PizzaService-war</context-root>
+       <class-loader delegate="true"/>
+       <jsp-config>
+               <property name="keepgenerated" value="true">
+                       <description>Keep a copy of the generated servlet class' java code.</description>
+               </property>
+       </jsp-config>
 </glassfish-web-app>
index 050ca2cee88c4efac101b688f1158f0065937b4b..409b30562c2eb543aff2127a96457d8a58e4d787 100644 (file)
@@ -6,19 +6,19 @@
 
        <div class="mini_basket_box">
                <div class="mini_basket_header">
-                       #{msg.mini_basket.header}
+                       #{msg.mini_basketController.header}
                </div>
 
                <div class="mini_basket_last">
-                       #{msg.mini_basket.last_item}
+                       #{msg.mini_basketController.last_item}
                </div>
 
                <div class="mini_basket_more">
-                       #{msg.mini_basket.additional_items}
+                       #{msg.mini_basketController.additional_items}
                </div>
 
                <div class="mini_basket_link">
-                       <h:link id="to_basket" outcome="basket" title="#{msg.mini_basket.to_basket}" value="#{msg.mini_basket.to_basket}" />
+                       <h:link id="to_basket" outcome="basket" title="#{msg.mini_basketController.to_basket}" value="#{msg.mini_basketController.to_basket}" />
                </div>
        </div>
 </ui:composition>
index ee4ced7e1fa6ff69ae120a97de9b8ad4af5a33ac..ec48401064af064e1b5581f527364d29aaa83afb 100644 (file)
@@ -6,12 +6,12 @@
        <ui:define name="title"><ui:insert name="guest_title" class="guest_title" /></ui:define>
 
        <!--
-       Show basket if it contains items, else show an empty basket.
+       Show basket if it contains items, else show an empty basketController.
        //-->
-       <ui:fragment rendered="#{basket.isEmpty()}">
+       <ui:fragment rendered="#{basketController.isEmpty()}">
                <ui:include src="/WEB-INF/templates/basket/mini_basket_empty.tpl" />
        </ui:fragment>
-       <ui:fragment rendered="#{basket.hasItems()}">
-               <ui:include src="/WEB-INF/templates/basket/mini_basket.tpl" />
+       <ui:fragment rendered="#{basketController.hasItems()}">
+               <ui:include src="/WEB-INF/templates/basket/mini_basketController.tpl" />
        </ui:fragment>
 </ui:composition>
index e87d25926b8d93b9276247a108905d2ab83087d6..aff9f901c3016b29f7d28ad734260af61973397e 100644 (file)
@@ -8,13 +8,13 @@
        <tag>
                <name>mini_basket</name>
                <description>A mini basket showing latest added item and a link to the full basket web page</description>
-               <tag-class>org.mxchange.pizzaapplication.tags.basket.MiniBasketTag</tag-class>
+               <tag-class>org.mxchange.pizzaapplication.tags.basketController.MiniBasketTag</tag-class>
                <attribute>
                        <name>basket</name>
                        <description>Basket instance, should be the same as the bean</description>
                        <required>true</required>
                        <rtexprvalue>true</rtexprvalue>
-                       <type>org.mxchange.jshopejb.beans.basket.BasketBean</type>
+                       <type>org.mxchange.jshopejb.beans.basketController.BasketBean</type>
                </attribute>
        </tag>
 </taglib>
index e612d608829881b47ae9fd7e42c2d7891c564f2c..aa0f90830d3acf19a32df3abb46211ac17d2c412 100644 (file)
                </ui:define>
 
                <ui:define name="content">
-                       <!--
-                       TODO Not used!
-                       <h:panelGrid class="basket_item_table" columnClasses="table_data_column" headerClass="table_header_column">
-                               <f:facet name="header">
-                                       Bestellen? Bestellmenge: Produkt: Einzelpreis:
-                               </f:facet>
-                       </h:panelGrid>
-                       //-->
-
-                       <table class="basket_item_table">
-                               <thead>
-                                       <tr>
-                                               <th colspan="5" class="table_header">
-                                                       Folgendes kann bestellt werden:
-                                               </th>
-                                       </tr>
-
-                                       <tr>
-                                               <th class="table_header_column">
-                                                       Bestellen?
-                                               </th>
-
-                                               <th class="table_header_column">
-                                                       Anzahl:
-                                               </th>
-
-                                               <th class="table_header_column">
-                                                       Produkt:
-                                               </th>
-
-                                               <th class="table_header_column">
-                                                       Einzelpreis:
-                                               </th>
-
-                                               <th class="table_header_column">
-                                                       Zwischensumme:
-                                               </th>
-                                       </tr>
-                               </thead>
-                       </table>
-
-                       <ui:repeat var="product" value="#{controller.availableProducts}">
-                               <ui:fragment rendered="#{basket.isProductAdded(product)}">
-                                       <table class="basket_item_table">
-                                               <tbody>
-                                                       <tr>
-                                                               <td class="table_data_column">
-                                                                       <h:link outcome="basket" title="Zum Warenkorb" value="Warenkorb" />
-                                                               </td>
-
-                                                               <td class="table_data_column">
-                                                                       #{basket.currentItem.amount}
-                                                               </td>
-
-                                                               <td class="table_data_column">
-                                                                       #{product.title}
-                                                               </td>
-
-                                                               <td class="table_data_column" align="right">
-                                                                       <h:outputText class="price" value="#{product.price}">
-                                                                               <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" />
-                                                                       </h:outputText>
-                                                               </td>
-
-                                                               <td class="table_data_column" align="right">
-                                                                       <h:outputText class="price" value="#{basket.calculateItemPrice()}">
-                                                                               <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" />
-                                                                       </h:outputText>
-                                                               </td>
-                                                       </tr>
-                                               </tbody>
-                                       </table>
-                               </ui:fragment>
-
-                               <ui:fragment rendered="#{basket.isProductAdded(product) == false}">
-                                       <h:form acceptcharset="utf-8" id="add_item">
-                                               <table class="basket_item_table">
-                                                       <tbody>
-                                                               <tr>
-                                                                       <td class="table_data_column">
-                                                                               <h:commandButton class="submit" id="add" value="Hinzufügen" action="#{basket.addItem(product)}" title="Fuegt das Produkt dem Warenkorb hinzu" />
-                                                                       </td>
-
-                                                                       <td class="table_data_column">
-                                                                               <h:inputText class="input" id="amount" size="3" maxlength="20" value="#{basket.amount}" required="true" requiredMessage="#{msg.ITEM_AMOUNT_IS_REQUIRED}" title="Geben Sie hier die Bestellmenge ein.">
-                                                                                       <!--
-                                                                                       If the customer wants to order more, he need to call in.
-                                                                                       //-->
-                                                                                       <f:validateLongRange for="amount" minimum="1" maximum="10" />
-                                                                               </h:inputText>
-                                                                       </td>
-
-                                                                       <td class="table_data_column">
-                                                                               #{product.title}
-                                                                       </td>
-
-                                                                       <td class="table_data_column" align="right">
-                                                                               <h:outputText class="price" value="#{product.price}">
-                                                                                       <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
-                                                                               </h:outputText>
-                                                                       </td>
-
-                                                                       <td class="table_data_column" align="right">
-                                                                               -
-                                                                       </td>
-                                                               </tr>
-                                                       </tbody>
-                                               </table>
-                                       </h:form>
-                               </ui:fragment>
-                       </ui:repeat>
+                       <h:form acceptcharset="utf-8" id="add_item">
+                               <div class="table">
+                                       <div class="table_header">
+                                               Folgendes kann bestellt werden:
+                                       </div>
+                               </div>
+
+                               <h:dataTable value="#{controller.availableProducts}" var="product" headerClass="table_header_column" class="table">
+                                       <h:column>
+                                               <f:facet name="header"><h:outputText value="Bestellen?" /></f:facet>
+                                               <h:commandButton class="submit" id="add" value="Hinzufügen" action="#{basketController.addItem(product)}" title="#{msg.BUTTON_TITLE_ADD_ITEM_TO_BASKET}" rendered="#{basketController.amount == null || basketController.amount == 0}" />
+                                               <h:link outcome="basket" title="Zum Warenkorb" value="Warenkorb" rendered="#{basketController.amount > 0}" />
+                                       </h:column>
+
+                                       <h:column>
+                                               <f:facet name="header"><h:outputText value="Anzahl:" /></f:facet>
+                                               <h:inputText class="input" id="amount" size="3" maxlength="20" value="#{basketController.amount}" title="#{msg.INPUT_TITLE_ENTER_ITEM_AMOUNT}">
+                                                       <!--
+                                                       If the customer wants to order more, he need to call in.
+                                                       //-->
+                                                       <f:validator for="amount" validatorId="ItemAmountValidator" />
+                                               </h:inputText>
+                                       </h:column>
+
+                                       <h:column>
+                                               <f:facet name="header"><h:outputText value="Produkt:" /></f:facet>
+                                               <h:outputText class="price" value="#{product.title}">
+                                                       <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
+                                               </h:outputText>
+                                       </h:column>
+
+                                       <h:column>
+                                               <f:facet name="header"><h:outputText value="Einzelpreis:" /></f:facet>
+                                               <h:outputText class="price" value="#{product.price}">
+                                                       <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
+                                               </h:outputText>
+                                       </h:column>
+
+                                       <h:column>
+                                               <f:facet name="header"><h:outputText value="Zwischensumme:" /></f:facet>
+                                               <h:outputText value="-" rendered="#{basketController.amount == null || basketController.amount == 0}" />
+                                               <h:outputText value="#{basketController.calculateItemPrice}" rendered="#{basketController.amount > 0}" />
+                                       </h:column>
+                               </h:dataTable>
+                       </h:form>
                </ui:define>
 
                <ui:define name="footer">