]> git.mxchange.org Git - pizzaservice-war.git/commitdiff
Continued with administrative customer stuff:
authorRoland Häder <roland@mxchange.org>
Mon, 25 Apr 2016 13:37:38 +0000 (15:37 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 27 Apr 2016 19:57:44 +0000 (21:57 +0200)
- added loading of full customer list on post-init phase
- added EJB (remote interface) for calling customer business methods
- added new depencies jcustomer-core/jcustomer-lib

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/de/chotime/jratecalc/beans/customer/RateCalcAdminCustomerWebRequestBean.java
src/java/de/chotime/jratecalc/beans/customer/RateCalcAdminCustomerWebRequestController.java
web/admin/customer/admin_customer_list.xhtml

index ba669e09c425c02c69ee697c7ae69eeac12d3531..dd6c4b5fe816f47ccac4e7b8c26310acae92d678 100644 (file)
  */
 package de.chotime.jratecalc.beans.customer;
 
+import de.chotime.jratecalc.model.customer.RateCalcAdminCustomerSessionBeanRemote;
+import java.util.Collections;
+import java.util.List;
+import javax.annotation.PostConstruct;
 import javax.enterprise.context.RequestScoped;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Named;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
+import org.mxchange.jcustomercore.model.customer.Customer;
 
 /**
  * Administrative customer bean (controller)
@@ -37,6 +42,16 @@ public class RateCalcAdminCustomerWebRequestBean implements RateCalcAdminCustome
         */
        private static final long serialVersionUID = 12_487_062_487_527_913L;
 
+       /**
+        * Customer EJB
+        */
+       private RateCalcAdminCustomerSessionBeanRemote adminCustomerBean;
+
+       /**
+        * A list of all customers
+        */
+       private List<Customer> customerList;
+
        /**
         * Default constructor
         */
@@ -47,11 +62,31 @@ public class RateCalcAdminCustomerWebRequestBean implements RateCalcAdminCustome
                        Context context = new InitialContext();
 
                        // Try to lookup
-                       //this.userBean = (UserSessionBeanRemote) context.lookup("java:global/jratecalc-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
+                       this.adminCustomerBean = (RateCalcAdminCustomerSessionBeanRemote) context.lookup("java:global/jratecalc-ejb/admincustomer!de.chotime.model.customer.RateCalcAdminCustomerSessionBeanRemote"); //NOI18N
                } catch (final NamingException e) {
                        // Throw again
                        throw new FaceletException(e);
                }
        }
 
+       @Override
+       public List<Customer> allCustomers () {
+               // Return it
+               return Collections.unmodifiableList(this.customerList);
+       }
+
+       @Override
+       public boolean hasCustomers () {
+               return (!this.allCustomers().isEmpty());
+       }
+
+       /**
+        * Post-initialization of this class
+        */
+       @PostConstruct
+       public void init () {
+               // Initialize customer list
+               this.customerList = this.adminCustomerBean.allCustomers();
+       }
+
 }
index 2e3ea8bf689d84402c20428f42183d654ae0dccd..bc50cd53a4d0e62e3b49f9172b9909d26a9281d0 100644 (file)
@@ -17,6 +17,8 @@
 package de.chotime.jratecalc.beans.customer;
 
 import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jcustomercore.model.customer.Customer;
 
 /**
  * An interface for user beans
@@ -25,4 +27,18 @@ import java.io.Serializable;
  */
 public interface RateCalcAdminCustomerWebRequestController extends Serializable {
 
+       /**
+        * All customer
+        * <p>
+        * @return A list of all customer profiles
+        */
+       List<Customer> allCustomers ();
+
+       /**
+        * Checks whether customers are registered
+        * <p>
+        * @return Whether customers are registered
+        */
+       boolean hasCustomers ();
+
 }
index b6731ae6459c3cbe8c72be697846b4758ac7cc2d..f8d6b7c9b87c2043686cf83eeb829fd6b1200d04 100644 (file)
                </ui:define>
 
                <ui:define name="content">
-                       Here goes your content.
+                       <h:dataTable id="table_list_customers" var="customer" value="#{adminCustomerController.allCustomers()}" styleClass="table_big" headerClass="table_header_column" summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_CUSTOMER}" rendered="#{adminCustomerController.hasCustomers()}">
+                               <h:column>
+                                       <f:facet name="header">#{msg.ADMIN_LIST__CUSTOMER_ID}</f:facet>
+
+                                       <h:link outcome="admin_show_customer" title="#{msg.ADMIN_LINK_SHOW__CUSTOMER_TITLE}" value="#{customer.customerId}">
+                                               <f:param name="customerId" value="#{customer.customerId}" />
+                                       </h:link>
+                               </h:column>
+
+                               <h:column>
+                                       <f:facet name="header">#{msg.ADMIN_LIST__CUSTOMER_NUMBER}</f:facet>
+
+                                       <h:outputText value="#{customer.customerNumber}" />
+                               </h:column>
+
+                               <h:column>
+                                       <f:facet name="header">#{msg.ADMIN_LIST__CUSTOMER_GENDER}</f:facet>
+
+                                       <h:outputText value="#{msg[customer.customerContact.contactGender.messageKey]}" />
+                               </h:column>
+
+                               <h:column>
+                                       <f:facet name="header">#{msg.ADMIN_LIST__CUSTOMER_FIRST_NAME}</f:facet>
+
+                                       <h:outputText value="#{customer.customerContact.contactFirstName}" />
+                               </h:column>
+
+                               <h:column>
+                                       <f:facet name="header">#{msg.ADMIN_LIST__CUSTOMER_FAMILY_NAME}</f:facet>
+
+                                       <h:outputText value="#{customer.customerContact.contactFamilyName}" />
+                               </h:column>
+
+                               <h:column>
+                                       <f:facet name="header">#{msg.ADMIN_LIST__CUSTOMER_ACCOUNT_STATUS}</f:facet>
+
+                                       <h:outputText styleClass="#{customer.customerAccountStatus.styleClass}" value="#{msg[customer.customerAccountStatus.messageKey]}" />
+                               </h:column>
+
+                               <h:column>
+                                       <f:facet name="header">#{msg.ADMIN_LIST__CUSTOMER_PROFILE_MODE}</f:facet>
+
+                                       <h:outputText value="#{msg[customer.customerProfileMode.messageKey]}" />
+                               </h:column>
+
+                               <h:column>
+                                       <f:facet name="header">#{msg.ADMIN_LIST__CUSTOMER_CREATED}</f:facet>
+
+                                       <h:outputText id="customerCreated" value="#{customer.customerCreated.time}">
+                                               <f:convertDateTime for="customerCreated" type="both" timeStyle="short" dateStyle="short" />
+                                       </h:outputText>
+                               </h:column>
+                       </h:dataTable>
+
+                       <div class="table">
+                               <h:form id="admin_add_customer">
+                                       <div class="table_header">
+                                               #{msg.ADMIN_ADD__CUSTOMER_TITLE}
+                                       </div>
+
+                                       <ui:include src="/WEB-INF/templates/admin/user/admin_form_user_personal_data.tpl" />
+
+                                       <div class="table_footer">
+                                               <h:commandButton class="reset" type="reset" value="#{msg.BUTTON_RESET_FORM}" />
+                                               <h:commandButton class="submit" type="submit" id="register" value="#{msg.BUTTON_ADMIN_ADD__CUSTOMER}" action="#{adminCustomerController.addCustomer()}" />
+                                       </div>
+                               </h:form>
+                       </div>
                </ui:define>
        </ui:composition>
 </html>