]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Continued:
authorRoland Haeder <roland@mxchange.org>
Mon, 14 Sep 2015 08:42:30 +0000 (10:42 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 14 Sep 2015 08:42:30 +0000 (10:42 +0200)
- refactured index page as this was not working (why, JSF team?)
- added very basic item basket (total amount to pay is missing + link to checkout page)
- updated jars
Signed-off-by:Roland Häder <roland@mxchange.org>

13 files changed:
lib/jcore-ee-logger.jar
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/product/AdminProductWebBean.java
web/admin/admin_logout.xhtml [new file with mode: 0644]
web/basket.xhtml
web/index.xhtml
web/resources/css/cssLayout.css

index 6d0e98ca34bb9da22fe71b465ba1765a785a8053..9631578315fa23cab8f95f90e90b3013588b16ea 100644 (file)
Binary files a/lib/jcore-ee-logger.jar and b/lib/jcore-ee-logger.jar differ
index 925c0588c2c33478379c56e9a328d3a9772393b1..20252ca040b5e56afe2e392067112c8f883da4a8 100644 (file)
Binary files a/lib/jcoreee.jar and b/lib/jcoreee.jar differ
index 7f20cac7221a506d524529a51cff14aaeb714ad1..f75447419029685bf29ca755e42c0eb418e4501b 100644 (file)
Binary files a/lib/jshop-core.jar and b/lib/jshop-core.jar differ
index 4970b7f66dac5d9e4d671cb65bb80c2b782786a0..58fc16d312005151273711d755ed4ba5887252b3 100644 (file)
Binary files a/lib/jshop-ee-lib.jar and b/lib/jshop-ee-lib.jar differ
index ab603346aea978ef4284a340ce7c0291451b91a9..d9aecd411916ecbc772e1f21090611b67a0c78db 100644 (file)
@@ -33,3 +33,4 @@ BUTTON_TITLE_ADD_ITEM_TO_BASKET=F\u00fcgt das Produkt dem Warenkorb hinzu.
 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.
index b465711a8050305937a213520f009b765cefa8b7..2080f6a755353dbaa551e627b2512e2acfbe2f71 100644 (file)
@@ -31,3 +31,4 @@ BUTTON_TITLE_ADD_ITEM_TO_BASKET=Adds the product to the basket.
 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.
index 89177ad398ad4bf09ee50e2d32227330bb245993..9adcfea5d38435f7557e7fda50c141b179036d19 100644 (file)
@@ -16,7 +16,7 @@
  */
 package org.mxchange.pizzaapplication.beans.basket;
 
-import java.util.Map;
+import java.util.List;
 import javax.annotation.PostConstruct;
 import javax.enterprise.context.SessionScoped;
 import javax.faces.FacesException;
@@ -115,7 +115,13 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl
        }
 
        @Override
-       public Float calculateItemPrice () {
+       public List<AddableBasketItem> allItems () {
+               // Deligate to basket instance
+               return this.basket.getAll();
+       }
+
+       @Override
+       public Float calculateCurrentItemPrice () {
                // Is the current item/amount set?
                if (this.getCurrentItem() == null) {
                        // Current item is null
@@ -135,6 +141,15 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl
                return totalPrice;
        }
 
+       @Override
+       public Float calculateItemPrice (final AddableBasketItem item) {
+               // Caculate item's price
+               Float totalPrice = (item.getProduct().getPrice() * item.getAmount());
+
+               // Return it
+               return totalPrice;
+       }
+
        @Override
        public Long getAmount () {
                return this.amount;
@@ -243,13 +258,10 @@ public class BasketWebBean extends BaseFrameworkBean implements BasketWebControl
                AddableBasketItem fake = new BasketItem(product);
 
                // Get all items
-               Map<Long, AddableBasketItem> map = this.basket.getAll();
+               List<AddableBasketItem> list = this.basket.getAll();
 
                // Check all entries
-               for (Map.Entry<Long, AddableBasketItem> entrySet : map.entrySet()) {
-                       // Get item
-                       AddableBasketItem item = entrySet.getValue();
-
+               for (final AddableBasketItem item : list) {
                        // item must not be null
                        if (null == item) {
                                // Abort here
index ad81ef88dcf318cf0299eaaf84d898a2c3120930..2f6c212e05f3b54dce92f1bbceec76b91472577a 100644 (file)
@@ -17,6 +17,7 @@
 package org.mxchange.pizzaapplication.beans.basket;
 
 import java.io.Serializable;
+import java.util.List;
 import org.mxchange.jshopcore.model.basket.AddableBasketItem;
 import org.mxchange.jshopcore.model.product.Product;
 
@@ -93,7 +94,15 @@ public interface BasketWebController extends Serializable {
         *
         * @return Current item's total price
         */
-       public Float calculateItemPrice ();
+       public Float calculateCurrentItemPrice ();
+
+       /**
+        * Calculates total price (no tax added) for given item.
+        *
+        * @param item Item instance to calculate total price for
+        * @return Total price
+        */
+       public Float calculateItemPrice (final AddableBasketItem item);
 
        /**
         * Getter for last entry
@@ -108,4 +117,11 @@ public interface BasketWebController extends Serializable {
         * @return Last num rows
         */
        public int getLastNumRows ();
+
+       /**
+        * Gets for all added items
+        *
+        * @return A list of all added items
+        */
+       public List<AddableBasketItem> allItems ();
 }
index c37417d877f3745f78f937100bc06e46410e009f..335ed468700ecddf09fe629619de1393392005bd 100644 (file)
@@ -26,9 +26,9 @@ 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.AdminProductSessionBeanRemote;
 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;
 
 /**
@@ -44,7 +44,6 @@ public class AdminProductWebBean extends BaseFrameworkBean implements AdminProdu
         * Serial number
         */
        private static final long serialVersionUID = 5_819_375_183_472_871L;
-       
 
        /**
         * Property available
@@ -64,7 +63,7 @@ public class AdminProductWebBean extends BaseFrameworkBean implements AdminProdu
        /**
         * Remote bean for products
         */
-       private final ProductSessionBeanRemote productBean;
+       private final AdminProductSessionBeanRemote productBean;
 
        /**
         * Shop bean
@@ -87,7 +86,7 @@ public class AdminProductWebBean extends BaseFrameworkBean implements AdminProdu
                InitialContext context = new InitialContext();
 
                // Try to lookup the bean
-               this.productBean = (ProductSessionBeanRemote) context.lookup("ejb/stateless-product"); //NOI18N
+               this.productBean = (AdminProductSessionBeanRemote) context.lookup("ejb/stateless-admin-product"); //NOI18N
        }
 
        @Override
@@ -136,7 +135,7 @@ public class AdminProductWebBean extends BaseFrameworkBean implements AdminProdu
        }
 
        @Override
-       public void setId (Long id) {
+       public void setId (final Long id) {
                this.id = id;
        }
 
diff --git a/web/admin/admin_logout.xhtml b/web/admin/admin_logout.xhtml
new file mode 100644 (file)
index 0000000..708bd90
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<html xmlns="http://www.w3.org/1999/xhtml"
+         xmlns:ui="http://java.sun.com/jsf/facelets"
+         xmlns:h="http://xmlns.jcp.org/jsf/html"
+         xmlns:f="http://xmlns.jcp.org/jsf/core"
+         >
+
+       <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
+               <ui:define name="admin_title">Ausloggen</ui:define>
+
+               <ui:define name="menu">
+                       <ui:include id="menu" class="admin_menu" src="/WEB-INF/templates/admin/admin_menu.tpl" />
+               </ui:define>
+
+               <ui:define name="content_header">
+                       Aus dem Adminbereich ausloggen
+               </ui:define>
+
+               <ui:define name="content">
+                       Offenes TODO.
+               </ui:define>
+
+               <ui:define name="footer">
+                       <ui:include id="footer" class="guest_footer" src="/WEB-INF/templates/admin/admin_footer.tpl" />
+               </ui:define>
+       </ui:composition>
+</html>
index 184cf2d19c846c1aca0c55e8a3143044100da916..ffe36a049dbc73f151999612fda0d012a5734ba6 100644 (file)
@@ -6,18 +6,61 @@
          >
 
        <ui:composition template="/WEB-INF/templates/guest/guest_base.tpl">
-               <ui:define name="guest_title">Warenkorb</ui:define>
+               <ui:define name="guest_title">Warenkorb anzeigen</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">
-                       Warenkorb
+                       Alle im Warenkorb befindlichen Artikel:
                </ui:define>
 
                <ui:define name="content">
-                       Hier wird der Warenkorb angezeigt.
+                       <h:dataTable var="item" value="#{basketController.allItems()}" headerClass="table_header_column" class="table" rendered="#{basketController.hasItems()}">
+                               <h:column>
+                                       <f:facet name="header">Artikel:</f:facet>
+
+                                       <ui:fragment rendered="#{item.isProductType()}">
+                                               #{item.product.title}
+                                       </ui:fragment>
+                               </h:column>
+
+                               <h:column>
+                                       <f:facet name="header">Einzelpreis:</f:facet>
+
+                                       <ui:fragment rendered="#{item.isProductType()}">
+                                               <h:outputText class="price" value="#{item.product.price}">
+                                                       <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
+                                               </h:outputText>
+                                       </ui:fragment>
+                               </h:column>
+
+                               <h:column>
+                                       <f:facet name="header">Anzahl ändern:</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}" />
+
+                                               <h:inputText class="input" id="amount" size="3" maxlength="20" value="#{item.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:form>
+                               </h:column>
+
+                               <h:column>
+                                       <f:facet name="header">Zwischensumme:</f:facet>
+
+                                       <h:outputText id="item_price" value="#{basketController.calculateItemPrice(item)}" rendered="#{item.isProductType()}">
+                                               <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
+                                       </h:outputText>
+                               </h:column>
+                       </h:dataTable>
+
+                       <h:outputText class="empty_basket" value="Es befinden sich derzeit keine Artikel im Warenkorb." rendered="#{basketController.isEmpty()}" />
                </ui:define>
 
                <ui:define name="footer">
index bd72baffe6a4b1c35fde8becd8b8ddb0342edaf4..4c3d08db60c4cff2effe5f040d04248b8f5c1528 100644 (file)
                </ui:define>
 
                <ui:define name="content">
-                       <h:form acceptcharset="utf-8" id="add_item">
-                               <div class="table">
-                                       <div class="table_header">
-                                               Folgendes kann bestellt werden:
-                                       </div>
+                       <div class="table">
+                               <div class="table_header">
+                                       Folgendes kann bestellt werden:
                                </div>
+                       </div>
+
+                       <h:dataTable value="#{controller.availableProducts}" var="product" class="table">
+                               <h:column>
+                                       <div id="main_item_container">
+                                               <div class="item_title">
+                                                        #{product.title}
+                                               </div>
+
+                                               <div class="item_content">
+                                                       <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: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: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:form>
+                                                               </ui:fragment>
 
-                                       <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>
+                                                               <ui:fragment rendered="#{basketController.isProductAdded(product)}">
+                                                                       <div class="item_amount">
+                                                                               #{basketController.amount}
+                                                                       </div>
 
-                                       <h:column>
-                                               <f:facet name="header"><h:outputText value="Produkt:" /></f:facet>
-                                               <h:outputText value="#{product.title}">
-                                                       <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
-                                               </h:outputText>
-                                       </h:column>
+                                                                       <div class="item_basket_link">
+                                                                               <h:link outcome="basket" title="Zum Warenkorb" value="Im Warenkorb ändern" />
+                                                                       </div>
 
-                                       <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>
+                                                                       <div class="clear"></div>
+                                                               </ui:fragment>
+                                                       </div>
 
-                                       <h:column>
-                                               <f:facet name="header"><h:outputText value="Zwischensumme:" /></f:facet>
-                                               <h:outputText class="price" value="-" rendered="#{basketController.amount == null || basketController.amount == 0}" />
-                                               <h:outputText class="price" value="#{basketController.calculateItemPrice}" rendered="#{basketController.amount > 0}" />
-                                       </h:column>
-                               </h:dataTable>
-                       </h:form>
+                                                       <div class="item_price">
+                                                               Einzelpreis:
+                                                               <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)}" />
+                                                               <h:outputText class="price" value="#{basketController.calculateCurrentItemPrice()}" rendered="#{basketController.isProductAdded(product)}">
+                                                                       <f:convertNumber type="currency" minFractionDigits="2" maxFractionDigits="2" locale="de_DE" />
+                                                               </h:outputText>
+                                                       </div>
+                                               </div>
+                                       </div>
+                               </h:column>
+                       </h:dataTable>
                </ui:define>
 
                <ui:define name="footer">
index 57d9001623c125e4543066825365717a09369ffd..ed37fb5ab647a5b78fe84d9892c3224284279ab9 100644 (file)
@@ -1,5 +1,5 @@
 /**
-div {
+div, table {
        border: 1px solid #ff0000;
 }
 /**/
@@ -115,7 +115,7 @@ table, .table {
 
 ul.footer_nav {
        text-align: center;
-       width : 100%;
+       /*width : 95%;*/
        list-style: none;
        margin: 0px;
 }