*/
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)
*/
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
*/
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();
+ }
+
}
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
*/
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 ();
+
}
</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>