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.
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.
*/
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;
}
@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
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;
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
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;
*
* @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
* @return Last num rows
*/
public int getLastNumRows ();
+
+ /**
+ * Gets for all added items
+ *
+ * @return A list of all added items
+ */
+ public List<AddableBasketItem> allItems ();
}
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;
/**
* Serial number
*/
private static final long serialVersionUID = 5_819_375_183_472_871L;
-
/**
* Property available
/**
* Remote bean for products
*/
- private final ProductSessionBeanRemote productBean;
+ private final AdminProductSessionBeanRemote productBean;
/**
* Shop bean
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
}
@Override
- public void setId (Long id) {
+ public void setId (final Long id) {
this.id = id;
}
--- /dev/null
+<?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>
>
<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">
</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">
/**
-div {
+div, table {
border: 1px solid #ff0000;
}
/**/
ul.footer_nav {
text-align: center;
- width : 100%;
+ /*width : 95%;*/
list-style: none;
margin: 0px;
}