]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
added admin helper usage (needed for overworked customer form)
authorRoland Häder <roland@mxchange.org>
Wed, 27 Apr 2016 09:37:44 +0000 (11:37 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 27 Apr 2016 20:19:10 +0000 (22:19 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/pizzaapplication/beans/customer/PizzaAdminCustomerWebRequestBean.java

index 7c9bbd62b4c1d20268e4e6b142d807e9aeaf0f09..4bdd3fbedf8dafd123594d7f7b3f9c218847860b 100644 (file)
@@ -35,6 +35,7 @@ import org.mxchange.jcustomercore.exceptions.CustomerAlreadyRegisteredException;
 import org.mxchange.jcustomercore.model.customer.Customer;
 import org.mxchange.jcustomercore.model.customer.status.CustomerAccountStatus;
 import org.mxchange.pizzaapplication.beans.contact.PizzaAdminContactWebRequestController;
+import org.mxchange.pizzaapplication.beans.helper.PizzaAdminWebRequestController;
 import org.mxchange.pizzaapplication.model.customer.PizzaAdminCustomerSessionBeanRemote;
 
 /**
@@ -62,6 +63,12 @@ public class PizzaAdminCustomerWebRequestBean implements PizzaAdminCustomerWebRe
         */
        private PizzaAdminCustomerSessionBeanRemote adminCustomerBean;
 
+       /**
+        * Admin helper instance
+        */
+       @Inject
+       private PizzaAdminWebRequestController adminHelper;
+
        /**
         * An event being fired when an administrator has added a new customer
         */
@@ -95,13 +102,22 @@ public class PizzaAdminCustomerWebRequestBean implements PizzaAdminCustomerWebRe
        @Override
        public String addCustomer () {
                // Are at least some fields added?
-               if (!this.isCustomerDataSet()) {
+               if ((this.adminHelper.getContact() == null) && (!this.isCustomerDataSet())) {
                        // Not all customer data is set
                        throw new FaceletException("Please provide minimum personal data: gender, first_name, family_name"); //NOI18N
                }
 
-               // Get contact instance
-               Contact contact = this.adminContactController.createContactInstance();
+               // Init contact
+               Contact contact;
+
+               // Is the contact set in helper?
+               if (this.adminHelper.getContact() instanceof Contact) {
+                       // Get from helper
+                       contact = this.adminHelper.getContact();
+               } else {
+                       // Get new contact instance
+                       contact = this.adminContactController.createContactInstance();
+               }
 
                // Ask the EJB for a free customer number
                String customerNumber = this.adminCustomerBean.createCustomerNumber();