2 * Copyright (C) 2016 Cho-Time GmbH
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package de.chotime.jratecalc.beans.customer;
19 import de.chotime.jratecalc.model.customer.RateCalcAdminCustomerSessionBeanRemote;
20 import java.util.Collections;
21 import java.util.List;
22 import javax.annotation.PostConstruct;
23 import javax.enterprise.context.RequestScoped;
24 import javax.faces.view.facelets.FaceletException;
25 import javax.inject.Named;
26 import javax.naming.Context;
27 import javax.naming.InitialContext;
28 import javax.naming.NamingException;
29 import org.mxchange.jcustomercore.model.customer.Customer;
32 * Administrative customer bean (controller)
34 * @author Roland Haeder<rhaeder@cho-time.de>
36 @Named ("adminCustomerController")
38 public class RateCalcAdminCustomerWebRequestBean implements RateCalcAdminCustomerWebRequestController {
43 private static final long serialVersionUID = 12_487_062_487_527_913L;
48 private RateCalcAdminCustomerSessionBeanRemote adminCustomerBean;
51 * A list of all customers
53 private List<Customer> customerList;
58 public RateCalcAdminCustomerWebRequestBean () {
61 // Get initial context
62 Context context = new InitialContext();
65 this.adminCustomerBean = (RateCalcAdminCustomerSessionBeanRemote) context.lookup("java:global/jratecalc-ejb/admincustomer!de.chotime.model.customer.RateCalcAdminCustomerSessionBeanRemote"); //NOI18N
66 } catch (final NamingException e) {
68 throw new FaceletException(e);
73 public List<Customer> allCustomers () {
75 return Collections.unmodifiableList(this.customerList);
79 public boolean hasCustomers () {
80 return (!this.allCustomers().isEmpty());
84 * Post-initialization of this class
88 // Initialize customer list
89 this.customerList = this.adminCustomerBean.allCustomers();