]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Maybe cherry-pick:
authorRoland Häder <roland@mxchange.org>
Sat, 28 Oct 2017 16:36:59 +0000 (18:36 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 28 Oct 2017 16:36:59 +0000 (18:36 +0200)
- added taglib for jproduct
- added input panel-grid JSF widget for entering product prices with taxes, net
  and gross price

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jfinancials/beans/product/FinancialAdminProductWebRequestBean.java
web/WEB-INF/product.jsf.taglib.xml [new file with mode: 0644]
web/WEB-INF/resources/tags/input/panel_grid/product/product_price_input_panel_grid.tpl [new file with mode: 0644]

index e212f6156e6b09ff0ec6307165dbddeca054c7e4..db8058be225c64585c419d5883a373fb2baf474c 100644 (file)
@@ -63,6 +63,11 @@ public class FinancialAdminProductWebRequestBean extends BaseFinancialsBean impl
         */
        private Category productCategory;
 
+       /**
+        * Product's price currency code like EUR or USD
+        */
+       private String productCurrencyCode;
+
        /**
         * Product's gross price
         */
@@ -160,6 +165,24 @@ public class FinancialAdminProductWebRequestBean extends BaseFinancialsBean impl
                this.productCategory = productCategory;
        }
 
+       /**
+        * Getter for product's price currency code
+        * <p>
+        * @return Product's price currency code
+        */
+       public String getProductCurrencyCode () {
+               return this.productCurrencyCode;
+       }
+
+       /**
+        * Setter for product's price currency code
+        * <p>
+        * @param productCurrencyCode Product's price currency code
+        */
+       public void setProductCurrencyCode (final String productCurrencyCode) {
+               this.productCurrencyCode = productCurrencyCode;
+       }
+
        /**
         * Getter for product's gross price
         * <p>
@@ -251,7 +274,7 @@ public class FinancialAdminProductWebRequestBean extends BaseFinancialsBean impl
         */
        private Product createProductInstance () {
                // Create product instance
-               final Product product = new GenericProduct(this.getProductTitle(), this.getProductGrossPrice(), this.getProductCategory(), this.getProductAvailability());
+               final Product product = new GenericProduct(this.getProductTitle(), this.getProductGrossPrice(), this.getProductCurrencyCode(), this.getProductCategory(), this.getProductAvailability());
 
                // Set all optional fields
                product.setProductNetPrice(this.getProductNetPrice());
diff --git a/web/WEB-INF/product.jsf.taglib.xml b/web/WEB-INF/product.jsf.taglib.xml
new file mode 100644 (file)
index 0000000..c59492d
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (C) 2017 Roland Häder
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as
+published by the Free Software Foundation, either version 3 of the
+License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+-->
+<facelet-taglib version="2.2"
+                               xmlns="http://xmlns.jcp.org/xml/ns/javaee"
+                               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                               xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facelettaglibrary_2_2.xsd">
+       <namespace>http://mxchange.org/jsf/jproduct/widgets</namespace>
+       <tag>
+               <tag-name>inputProductPricePanelGrid</tag-name>
+               <description>This tag renders input fields for creating a price panel grid for product prices.</description>
+               <source>resources/tags/input/panel_grid/product/product_price_input_panel_grid.tpl</source>
+               <attribute>
+                       <name>rendered</name>
+                       <description>Whether this tag is being rendered by JSF engine (default: true).</description>
+                       <required>false</required>
+                       <type>java.lang.Boolean</type>
+               </attribute>
+               <attribute>
+                       <name>targetController</name>
+                       <description>A target backing bean (EL code resolving into it) extending at least BaseFacesBean where to set the data in.</description>
+                       <required>true</required>
+                       <!-- @TODO Find an interface for BaseFacesBean and set it here instead -->
+                       <type>org.mxchange.jcoreee.bean.faces.BaseFacesBean</type>
+               </attribute>
+       </tag>
+</facelet-taglib>
diff --git a/web/WEB-INF/resources/tags/input/panel_grid/product/product_price_input_panel_grid.tpl b/web/WEB-INF/resources/tags/input/panel_grid/product/product_price_input_panel_grid.tpl
new file mode 100644 (file)
index 0000000..158d257
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<ui:composition
+       xmlns="http://www.w3.org/1999/xhtml"
+       xmlns:f="http://java.sun.com/jsf/core"
+       xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
+       xmlns:p="http://primefaces.org/ui">
+
+       <!-- @TODO Hard-coded values below -->
+       <p:panelGrid layout="grid" columns="3" styleClass="table table-full ui-noborder" rendered="#{empty rendered or rendered == true}">
+               <p:inputNumber
+                       id="productNetPrice"
+                       value="#{targetController.productNetPrice}"
+                       symbol=" EUR"
+                       symbolPosition="s"
+                       decimalSeparator=","
+                       thousandSeparator="."
+                       >
+               </p:inputNumber>
+
+               <p:inputNumber
+                       id="productTaxRate"
+                       value="#{targetController.productTaxRate}"
+                       symbol="%"
+                       symbolPosition="s"
+                       decimalSeparator=","
+                       emptyValue="sign"
+                       >
+                       <f:validateDoubleRange minimum="0" maximum="100" />
+               </p:inputNumber>
+
+               <p:inputNumber
+                       id="productGrossPrice"
+                       value="#{targetController.productGrossPrice}"
+                       symbol=" EUR"
+                       symbolPosition="s"
+                       decimalSeparator=","
+                       thousandSeparator="."
+                       required="true"
+                       requiredMessage="#{project.ADMIN_PRODUCT_GROSS_PRICE_REQUIRED}"
+                       >
+               </p:inputNumber>
+       </p:panelGrid>
+</ui:composition>