]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Thu, 2 Apr 2020 13:38:24 +0000 (15:38 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 2 Apr 2020 13:38:24 +0000 (15:38 +0200)
- rewrote admin-departments-list view to have working filters and sorting
  (wasn't done correctly)
- also included a "global" search (all columns)
- moved isDepartmentAlreadyAdded() to departmentListController to avoid getter
  for allDepartments being exposed in interface

Signed-off-by: Roland Häder <roland@mxchange.org>
12 files changed:
src/java/org/mxchange/jfinancials/beans/business/department/FinancialsAdminDepartmentWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/business/department/FinancialsDepartmentWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/business/department/FinancialsDepartmentWebRequestController.java
src/java/org/mxchange/jfinancials/beans/business/department/list/FinancialsDepartmentListWebViewBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/business/department/list/FinancialsDepartmentListWebViewtController.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/converter/business/department/FinancialsDepartmentConverter.java
src/java/org/mxchange/localization/generic_de_DE.properties
src/java/org/mxchange/localization/generic_en_US.properties
web/WEB-INF/resources/tags/country/form_data/form_country_selector.tpl
web/admin/branch_office/admin_branch_office_list.xhtml
web/admin/department/admin_department_list.xhtml
web/admin/mobile_provider/admin_mobile_provider_list.xhtml

index 27b15938ff0445126bbbbdce590275e709fae207..f4ec53657f1645e7f40408a2c3088597b9313faa 100644 (file)
@@ -16,7 +16,6 @@
  */
 package org.mxchange.jfinancials.beans.business.department;
 
-import java.util.List;
 import javax.ejb.EJB;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Event;
@@ -31,10 +30,10 @@ import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
 import org.mxchange.jcontactsbusiness.model.department.AdminDepartmentSessionBeanRemote;
 import org.mxchange.jcontactsbusiness.model.department.BusinessDepartment;
 import org.mxchange.jcontactsbusiness.model.department.Department;
-import org.mxchange.jcontactsbusiness.model.department.Departments;
 import org.mxchange.jcontactsbusiness.model.employee.Employable;
 import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
 import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.business.department.list.FinancialsDepartmentListWebViewtController;
 import org.mxchange.jusercore.model.user.User;
 
 /**
@@ -74,12 +73,6 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean
         */
        private BasicData departmentCompany;
 
-       /**
-        * A general department controller (backing bean)
-        */
-       @Inject
-       private FinancialsDepartmentWebRequestController departmentController;
-
        /**
         * Assigned headquarter (if apply-able)
         */
@@ -95,6 +88,12 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean
         */
        private Employable departmentLead;
 
+       /**
+        * A general department controller (backing bean)
+        */
+       @Inject
+       private FinancialsDepartmentListWebViewtController departmentListController;
+
        /**
         * Owning user instance (which this department is assigned to)
         */
@@ -118,7 +117,7 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean
                final Department department = this.createDepartment();
 
                // Is the department not created yet?
-               if (this.isDepartmentCreatedByRequiredData(department)) {
+               if (this.departmentListController.isDepartmentAlreadyAdded(department)) {
                        // Then show proper faces message
                        this.showFacesMessage("form-admin-add-department:branchStreet", "ADMIN_DEPARTMENT_ALREADY_CREATED"); //NOI18N
                        return;
@@ -269,34 +268,4 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean
                return department;
        }
 
-       /**
-        * Checks whether the given department is already found in local cache.
-        * Please note that this method fully relies on the cache, so you must
-        * always fire proper events that add/update/delete entries in cache.
-        * <p>
-        * @param department Department to check it's address
-        * <p>
-        * @return Whether the address has been found
-        */
-       private boolean isDepartmentCreatedByRequiredData (final Department department) {
-               // Get full list from other bean
-               final List<Department> departments = this.departmentController.allDepartments();
-
-               // Default is not found
-               boolean isFound = false;
-
-               // Now check each entry
-               for (final Department dep : departments) {
-                       // Is same address?
-                       if (Departments.isSameDepartment(dep, department)) {
-                               // Found one
-                               isFound = true;
-                               break;
-                       }
-               }
-
-               // Return flag
-               return isFound;
-       }
-
 }
index 35884c8a87d1706c33d2c7fd00b386593a0fdfc7..d2ecea68e81569e4e1c684c44b95a4d59429e981 100644 (file)
  */
 package org.mxchange.jfinancials.beans.business.department;
 
-import fish.payara.cdi.jsr107.impl.NamedCache;
-import java.text.MessageFormat;
-import java.util.Comparator;
-import java.util.LinkedList;
-import java.util.List;
-import javax.annotation.PostConstruct;
-import javax.cache.Cache;
 import javax.ejb.EJB;
 import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Observes;
-import javax.inject.Inject;
 import javax.inject.Named;
-import org.mxchange.jcontactsbusiness.events.department.added.ObservableDepartmentAddedEvent;
-import org.mxchange.jcontactsbusiness.exceptions.department.DepartmentNotFoundException;
-import org.mxchange.jcontactsbusiness.model.department.Department;
 import org.mxchange.jcontactsbusiness.model.department.DepartmentSessionBeanRemote;
 import org.mxchange.jfinancials.beans.BaseFinancialsBean;
 
@@ -48,150 +36,18 @@ public class FinancialsDepartmentWebRequestBean extends BaseFinancialsBean imple
         */
        private static final long serialVersionUID = 5_028_697_360_461L;
 
-       /**
-        * A list of all departments
-        */
-       private final List<Department> allDepartments;
-
        /**
         * EJB for administrative purposes
         */
        @EJB (lookup = "java:global/jfinancials-ejb/department!org.mxchange.jcontactsbusiness.model.department.DepartmentSessionBeanRemote")
        private DepartmentSessionBeanRemote departmentBean;
 
-       /**
-        * A list of all departments (globally)
-        */
-       @Inject
-       @NamedCache (cacheName = "departmentCache")
-       private Cache<Long, Department> departmentCache;
-
-       /**
-        * A list of filtered departments
-        */
-       private List<Department> filteredDepartments;
-
        /**
         * Default constructor
         */
        public FinancialsDepartmentWebRequestBean () {
                // Call super constructor
                super();
-
-               // Init list
-               this.allDepartments = new LinkedList<>();
-       }
-
-       /**
-        * Observes events being fired when a department has been added.
-        * <p>
-        * @param event Event being fired
-        * <p>
-        * @throws NullPointerException If the parameter or it's carried instance is
-        * null
-        * @throws IllegalArgumentException If the branchId is zero or lower
-        */
-       public void afterDepartmentAddedEvent (@Observes final ObservableDepartmentAddedEvent event) {
-               // Validate parameter
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getDepartment() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.department is null"); //NOI18N
-               } else if (event.getDepartment().getDepartmentId() == null) {
-                       // Throw it again
-                       throw new NullPointerException("event.department.branchId is null"); //NOI18N
-               } else if (event.getDepartment().getDepartmentId() < 1) {
-                       // Throw IAE
-                       throw new IllegalArgumentException(MessageFormat.format("event.department.branchId={0} is not valid", event.getDepartment().getDepartmentId())); //NOI18N
-               }
-
-               // Add instance to cache
-               this.departmentCache.put(event.getDepartment().getDepartmentId(), event.getDepartment());
-               this.allDepartments.add(event.getDepartment());
-       }
-
-       @Override
-       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
-       public List<Department> allDepartments () {
-               return this.allDepartments;
-       }
-
-       @Override
-       public Department findDepartmentById (final Long departmentId) throws DepartmentNotFoundException {
-               // Validate parameter
-               if (null == departmentId) {
-                       // Throw NPE
-                       throw new NullPointerException("departmentId is null"); //NOI18N
-               } else if (departmentId < 1) {
-                       // Throw IAE
-                       throw new IllegalArgumentException("departmentId=" + departmentId + " is invalid"); //NOI18N
-               } else if (!this.departmentCache.containsKey(departmentId)) {
-                       // Not found
-                       throw new DepartmentNotFoundException(departmentId);
-               }
-
-               // Get it from cache
-               final Department department = this.departmentCache.get(departmentId);
-
-               // Return it
-               return department;
-       }
-
-       /**
-        * Getter for a list of filtered departments
-        * <p>
-        * @return Filtered departments
-        */
-       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
-       public List<Department> getFilteredDepartments () {
-               return this.filteredDepartments;
-       }
-
-       /**
-        * Setter for a list of filtered departments
-        * <p>
-        * @param filteredDepartments Filtered departments
-        */
-       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
-       public void setFilteredDepartments (final List<Department> filteredDepartments) {
-               this.filteredDepartments = filteredDepartments;
-       }
-
-       /**
-        * Initializer method
-        */
-       @PostConstruct
-       public void initializeList () {
-               // Is cache there?
-               if (!this.departmentCache.iterator().hasNext()) {
-                       // Get whole list from EJB
-                       final List<Department> departments = this.departmentBean.allDepartments();
-
-                       // Add all
-                       for (final Department department : departments) {
-                               // Add it to cache
-                               this.departmentCache.put(department.getDepartmentId(), department);
-                       }
-               }
-
-               // Is the list empty, but filled cache?
-               if (this.allDepartments.isEmpty() && this.departmentCache.iterator().hasNext()) {
-                       // Build up list
-                       for (final Cache.Entry<Long, Department> currentEntry : this.departmentCache) {
-                               // Add to list
-                               this.allDepartments.add(currentEntry.getValue());
-                       }
-
-                       // Sort list
-                       this.allDepartments.sort(new Comparator<Department>() {
-                               @Override
-                               public int compare (final Department department1, final Department department2) {
-                                       return department1.getDepartmentId() > department2.getDepartmentId() ? 1 : department1.getDepartmentId() < department2.getDepartmentId() ? -1 : 0;
-                               }
-                       });
-               }
        }
 
 }
index 5a8374d097434cc570e2ca6ef2ba3506dd926411..5a106a30ca2c28a9198c2aff7cb65a4581d1104a 100644 (file)
@@ -17,9 +17,6 @@
 package org.mxchange.jfinancials.beans.business.department;
 
 import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jcontactsbusiness.exceptions.department.DepartmentNotFoundException;
-import org.mxchange.jcontactsbusiness.model.department.Department;
 
 /**
  * An interface for general department controller
@@ -28,24 +25,4 @@ import org.mxchange.jcontactsbusiness.model.department.Department;
  */
 public interface FinancialsDepartmentWebRequestController extends Serializable {
 
-       /**
-        * Returns a list of all departments
-        * <p>
-        * @return A list of all departments
-        */
-       List<Department> allDepartments ();
-
-       /**
-        * Retrieves a single company department entity for given id number or
-        * throws a proper exception if not found.
-        * <p>
-        * @param departmentId Company department id to lookup
-        * <p>
-        * @return Company department instance
-        * <p>
-        * @throws DepartmentNotFoundException If the id number could not be
-        * looked up and solved into an entity
-        */
-       Department findDepartmentById (final Long departmentId) throws DepartmentNotFoundException;
-
 }
diff --git a/src/java/org/mxchange/jfinancials/beans/business/department/list/FinancialsDepartmentListWebViewBean.java b/src/java/org/mxchange/jfinancials/beans/business/department/list/FinancialsDepartmentListWebViewBean.java
new file mode 100644 (file)
index 0000000..37cffa5
--- /dev/null
@@ -0,0 +1,244 @@
+/*
+ * Copyright (C) 2017 - 2020 Free Software Foundation
+ *
+ * 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/>.
+ */
+package org.mxchange.jfinancials.beans.business.department.list;
+
+import fish.payara.cdi.jsr107.impl.NamedCache;
+import java.text.MessageFormat;
+import java.util.Comparator;
+import java.util.LinkedList;
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.cache.Cache;
+import javax.ejb.EJB;
+import javax.enterprise.event.Observes;
+import javax.faces.view.ViewScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jcontactsbusiness.events.department.added.ObservableDepartmentAddedEvent;
+import org.mxchange.jcontactsbusiness.exceptions.department.DepartmentNotFoundException;
+import org.mxchange.jcontactsbusiness.model.department.Department;
+import org.mxchange.jcontactsbusiness.model.department.DepartmentSessionBeanRemote;
+import org.mxchange.jcontactsbusiness.model.department.Departments;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+
+/**
+ * A list bean for departments
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("departmentListController")
+@ViewScoped
+public class FinancialsDepartmentListWebViewBean extends BaseFinancialsBean implements FinancialsDepartmentListWebViewtController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 5_028_697_360_462L;
+
+       /**
+        * A list of all departments
+        */
+       private final List<Department> allDepartments;
+
+       /**
+        * EJB for administrative purposes
+        */
+       @EJB (lookup = "java:global/jfinancials-ejb/department!org.mxchange.jcontactsbusiness.model.department.DepartmentSessionBeanRemote")
+       private DepartmentSessionBeanRemote departmentBean;
+
+       /**
+        * A list of all departments (globally)
+        */
+       @Inject
+       @NamedCache (cacheName = "departmentCache")
+       private transient Cache<Long, Department> departmentCache;
+
+       /**
+        * A list of filtered departments
+        */
+       private List<Department> filteredDepartments;
+
+       /**
+        * Currently selected department
+        */
+       private Department selectedDepartment;
+
+       /**
+        * Default constructor
+        */
+       public FinancialsDepartmentListWebViewBean () {
+               // Call super constructor
+               super();
+
+               // Init list
+               this.allDepartments = new LinkedList<>();
+       }
+
+       /**
+        * Observes events being fired when a department has been added.
+        * <p>
+        * @param event Event being fired
+        * <p>
+        * @throws NullPointerException If the parameter or it's carried instance is
+        * null
+        * @throws IllegalArgumentException If the branchId is zero or lower
+        */
+       public void afterDepartmentAddedEvent (@Observes final ObservableDepartmentAddedEvent event) {
+               // Validate parameter
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getDepartment() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.department is null"); //NOI18N
+               } else if (event.getDepartment().getDepartmentId() == null) {
+                       // Throw it again
+                       throw new NullPointerException("event.department.branchId is null"); //NOI18N
+               } else if (event.getDepartment().getDepartmentId() < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("event.department.branchId={0} is not valid", event.getDepartment().getDepartmentId())); //NOI18N
+               }
+
+               // Add instance to cache
+               this.departmentCache.put(event.getDepartment().getDepartmentId(), event.getDepartment());
+               this.getAllDepartments().add(event.getDepartment());
+       }
+
+       @Override
+       public Department findDepartmentById (final Long departmentId) throws DepartmentNotFoundException {
+               // Validate parameter
+               if (null == departmentId) {
+                       // Throw NPE
+                       throw new NullPointerException("departmentId is null"); //NOI18N
+               } else if (departmentId < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("departmentId=" + departmentId + " is invalid"); //NOI18N
+               } else if (!this.departmentCache.containsKey(departmentId)) {
+                       // Not found
+                       throw new DepartmentNotFoundException(departmentId);
+               }
+
+               // Get it from cache
+               final Department department = this.departmentCache.get(departmentId);
+
+               // Return it
+               return department;
+       }
+
+       /**
+        * Returns a list of all departments
+        * <p>
+        * @return A list of all departments
+        */
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<Department> getAllDepartments () {
+               return this.allDepartments;
+       }
+
+       /**
+        * Getter for a list of filtered departments
+        * <p>
+        * @return Filtered departments
+        */
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<Department> getFilteredDepartments () {
+               return this.filteredDepartments;
+       }
+
+       /**
+        * Setter for a list of filtered departments
+        * <p>
+        * @param filteredDepartments Filtered departments
+        */
+       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+       public void setFilteredDepartments (final List<Department> filteredDepartments) {
+               this.filteredDepartments = filteredDepartments;
+       }
+
+       /**
+        * Getter for selected department
+        * <p>
+        * @return Selected department
+        */
+       public Department getSelectedDepartment () {
+               return this.selectedDepartment;
+       }
+
+       /**
+        * Setter for selected department
+        * <p>
+        * @param selectedDepartment Selected department
+        */
+       public void setSelectedDepartment (final Department selectedDepartment) {
+               this.selectedDepartment = selectedDepartment;
+       }
+
+       /**
+        * Initializer method
+        */
+       @PostConstruct
+       public void initializeList () {
+               // Is cache there?
+               if (!this.departmentCache.iterator().hasNext()) {
+                       // Get whole list from EJB
+                       final List<Department> departments = this.departmentBean.allDepartments();
+
+                       // Add all
+                       for (final Department department : departments) {
+                               // Add it to cache
+                               this.departmentCache.put(department.getDepartmentId(), department);
+                       }
+               }
+
+               // Is the list empty, but filled cache?
+               if (this.getAllDepartments().isEmpty() && this.departmentCache.iterator().hasNext()) {
+                       // Build up list
+                       for (final Cache.Entry<Long, Department> currentEntry : this.departmentCache) {
+                               // Add to list
+                               this.getAllDepartments().add(currentEntry.getValue());
+                       }
+
+                       // Sort list
+                       this.getAllDepartments().sort(new Comparator<Department>() {
+                               @Override
+                               public int compare (final Department department1, final Department department2) {
+                                       return department1.getDepartmentId() > department2.getDepartmentId() ? 1 : department1.getDepartmentId() < department2.getDepartmentId() ? -1 : 0;
+                               }
+                       });
+               }
+       }
+
+       @Override
+       public boolean isDepartmentAlreadyAdded (final Department department) {
+               // Default is not found
+               boolean isFound = false;
+
+               // Now check each entry
+               for (final Department currentDepartment : this.getAllDepartments()) {
+                       // Is same address?
+                       if (Departments.isSameDepartment(currentDepartment, department)) {
+                               // Found one
+                               isFound = true;
+                               break;
+                       }
+               }
+
+               // Return flag
+               return isFound;
+       }
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/business/department/list/FinancialsDepartmentListWebViewtController.java b/src/java/org/mxchange/jfinancials/beans/business/department/list/FinancialsDepartmentListWebViewtController.java
new file mode 100644 (file)
index 0000000..b256ae0
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2017 - 2020 Free Software Foundation
+ *
+ * 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/>.
+ */
+package org.mxchange.jfinancials.beans.business.department.list;
+
+import java.io.Serializable;
+import org.mxchange.jcontactsbusiness.exceptions.department.DepartmentNotFoundException;
+import org.mxchange.jcontactsbusiness.model.department.Department;
+
+/**
+ * An interface for general department controller
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsDepartmentListWebViewtController extends Serializable {
+
+       /**
+        * Retrieves a single company department entity for given id number or
+        * throws a proper exception if not found.
+        * <p>
+        * @param departmentId Company department id to lookup
+        * <p>
+        * @return Company department instance
+        * <p>
+        * @throws DepartmentNotFoundException If the id number could not be looked
+        * up and solved into an entity
+        */
+       Department findDepartmentById (final Long departmentId) throws DepartmentNotFoundException;
+
+       /**
+        * Checks whether the given department is already found in local cache.
+        * Please note that this method fully relies on the cache, so you must
+        * always fire proper events that add/update/delete entries in cache.
+        * <p>
+        * @param department Department to check it's address
+        * <p>
+        * @return Whether the address has been found
+        */
+       boolean isDepartmentAlreadyAdded (final Department department);
+
+}
index dc501057def52a5daa17e10f7569263ef0285597..ddd779f6d39d0110e349b29e95eba000d44661c1 100644 (file)
@@ -24,8 +24,8 @@ import javax.faces.convert.ConverterException;
 import javax.faces.convert.FacesConverter;
 import org.mxchange.jcontactsbusiness.exceptions.department.DepartmentNotFoundException;
 import org.mxchange.jcontactsbusiness.model.department.Department;
-import org.mxchange.jfinancials.beans.business.department.FinancialsDepartmentWebRequestBean;
-import org.mxchange.jfinancials.beans.business.department.FinancialsDepartmentWebRequestController;
+import org.mxchange.jfinancials.beans.business.department.list.FinancialsDepartmentListWebViewBean;
+import org.mxchange.jfinancials.beans.business.department.list.FinancialsDepartmentListWebViewtController;
 
 /**
  * Converter for company department id <-> instance
@@ -38,16 +38,10 @@ public class FinancialsDepartmentConverter implements Converter<Department> {
        /**
         * Company department EJB
         */
-       private static FinancialsDepartmentWebRequestController DEPARTMENT_CONTROLLER;
+       private static FinancialsDepartmentListWebViewtController DEPARTMENT_LIST_CONTROLLER;
 
        @Override
        public Department getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
-               // Is the instance there?
-               if (null == DEPARTMENT_CONTROLLER) {
-                       // Get bean from CDI directly
-                       DEPARTMENT_CONTROLLER = CDI.current().select(FinancialsDepartmentWebRequestBean.class).get();
-               }
-
                // Is the value null or empty?
                if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
                        // Warning message
@@ -64,8 +58,14 @@ public class FinancialsDepartmentConverter implements Converter<Department> {
                        // Try to parse the value as long
                        final Long departmentId = Long.valueOf(submittedValue);
 
+                       // Is the instance there?
+                       if (null == DEPARTMENT_LIST_CONTROLLER) {
+                               // Get bean from CDI directly
+                               DEPARTMENT_LIST_CONTROLLER = CDI.current().select(FinancialsDepartmentListWebViewBean.class).get();
+                       }
+
                        // Try to get user instance from it
-                       companyDepartment = DEPARTMENT_CONTROLLER.findDepartmentById(departmentId);
+                       companyDepartment = DEPARTMENT_LIST_CONTROLLER.findDepartmentById(departmentId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index cea7dd9c46dc5fa251a073f4660a57e0a9d79a26..1339124dd21874293f3e265fcb0c3796070a4c30 100644 (file)
@@ -1212,3 +1212,4 @@ ADMIN_MANUFACTURER_HEADER=Hersteller:
 ADMIN_ASSIGNED_MANUFACTURER_LABEL=Zugewiesener Hersteller:
 BARCODE=Barcode:
 ADMIN_CONTACT_DETAILS_HEADER=Kontaktdaten zu {0} {1} {2}:
+ADMIN_DEPARTMENT_DETAILS_HEADER=Daten der Abteilung {0} (Id {1}):
index 4dbf9617627495b3ec9d328df861734179f8b8c5..b80ddb53f718be76d09c110345625e8e1cce90ea 100644 (file)
@@ -1123,3 +1123,4 @@ ADMIN_MANUFACTURER_HEADER=Manufacturer:
 ADMIN_ASSIGNED_MANUFACTURER_LABEL=Assigned manufacturer:
 BARCODE=Barcode:
 ADMIN_CONTACT_DETAILS_HEADER=Contact data of {0} {1} {2}:
+ADMIN_DEPARTMENT_DETAILS_HEADER=Data of department {0} (Id {1}):
index b3369930ebdb16ee5868f43cce26787b8bf2d69d..0c154ca3c709da8df4d228a90aec72190a3c0982 100644 (file)
@@ -21,7 +21,7 @@
                <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" rendered="#{empty allowNull or allowNull}" />
 
                <f:selectItems
-                       value="#{countryController.allCountries()}"
+                       value="#{countryListController.allCountries}"
                        var="country"
                        itemValue="#{country}"
                        itemLabel="#{country.countryCode} (#{msg[country.countryI18nKey]})"
index f0532eae4bc5ba38df84d1465337c06981029cf5..5abdb2b272b59f5760eebebbe47ed18e19de7a17 100644 (file)
@@ -76,7 +76,7 @@
 
                                <p:ajax
                                        event="rowSelect"
-                                       update=":master:form-list-branch-offices:branchOffice-details"
+                                       update=":master:form-list-branch-offices:branch-office-details"
                                        oncomplete="PF('branchOfficeDialog').show()"
                                        />
 
                                responsive="true"
                                closeOnEscape="true"
                                >
-                               <p:outputPanel id="branchOffice-details">
+                               <p:outputPanel id="branch-office-details">
                                        <p:tabView>
                                                <p:tab title="#{msg.ADMIN_BRANCH_OFFICE_DATA_TAB_TITLE}">
                                                        <p:panelGrid columns="2" rendered="#{not empty branchOfficeListController.selectedBranchOffice}">
index a52836bcf73060ca9852019417bf30135d92eb70..4f72454935a31c7d71dd264be5a698e8d717e72a 100644 (file)
        </ui:define>
 
        <ui:define name="content">
-               <h:form id="form-list-department">
+               <h:form id="form-list-departments">
                        <p:dataTable
                                id="departmentList"
                                var="department"
-                               value="#{departmentController.allDepartments()}"
+                               value="#{departmentListController.allDepartments}"
                                paginator="true"
                                paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
-                               filteredValue="#{departmentController.filteredDepartments}"
+                               filteredValue="#{departmentListController.filteredDepartments}"
                                rows="10"
+                               rowKey="#{department.departmentId}"
                                reflow="true"
                                resizableColumns="true"
                                rowsPerPageTemplate="5,10,20,50,100"
                                summary="#{msg.TABLE_SUMMARY_ADMIN_LIST_DEPARTMENTS}"
                                emptyMessage="#{msg.ADMIN_EMPTY_LIST_DEPARTMENTS}"
                                widgetVar="departmentList"
+                               selectionMode="single"
+                               selection="#{departmentListController.selectedDepartment}"
+                               skipChildren="true"
                                >
 
                                <f:facet name="header">
-                                       <p:panelGrid columns="2" columnClasses="ui-grid-col-10,ui-grid-col-2" layout="grid" styleClass="ui-noborder ui-transparent-widget">
-                                               <h:outputText value="#{msg.ADMIN_LIST_DEPARTMENTS_HEADER}" />
+                                       <p:panelGrid
+                                               columns="3"
+                                               layout="grid"
+                                               columnClasses="ui-grid-col-4,ui-grid-col-6,ui-grid-col-2"
+                                               >
+                                               <p:spacer />
+
+                                               <p:panelGrid
+                                                       columns="2"
+                                                       columnClasses="ui-grid-4,ui-grid-8"
+                                                       layout="grid"
+                                                       styleClass="ui-noborder"
+                                                       >
+                                                       <p:outputLabel for="globalFilter" value="#{msg.SEARCH_ALL_FIELDS}" style="float: right" />
+                                                       <p:inputText id="globalFilter" onkeyup="PF('departmentList').filter()" placeholder="#{msg.ENTER_KEYWORD}"/>
+                                               </p:panelGrid>
+
+                                               <p:outputPanel>
+                                                       <p:spacer height="4" />
 
-                                               <h:panelGroup>
                                                        <p:commandButton
                                                                id="toggler"
                                                                type="button"
                                                                />
 
                                                        <p:columnToggler datasource="departmentList" trigger="toggler" />
-                                               </h:panelGroup>
+                                               </p:outputPanel>
                                        </p:panelGrid>
                                </f:facet>
 
+                               <p:ajax
+                                       event="rowSelect"
+                                       update=":master:form-list-departments:department-details"
+                                       oncomplete="PF('departmentDialog').show()"
+                                       />
+
                                <p:column
                                        headerText="#{msg.ID_HEADER}"
                                        sortBy="#{department.departmentId}"
                                        <links:outputDepartmentAdminDropdownMenu department="#{department}" />
                                </p:column>
                        </p:dataTable>
+
+                       <p:dialog
+                               dynamic="true"
+                               modal="true"
+                               resizable="false"
+                               header="#{msg.ADMIN_SINGLE_DEPARTMENT_DETAILS_HEADER}"
+                               hideEffect="fade"
+                               showEffect="fade"
+                               widgetVar="departmentDialog"
+                               position="top"
+                               responsive="true"
+                               closeOnEscape="true"
+                               >
+                               <p:outputPanel id="department-details">
+                                       <p:panelGrid columns="2" rendered="#{not empty departmentListController.selectedDepartment}">
+                                               <f:facet name="header">
+                                                       <h:outputFormat value="#{msg.ADMIN_DEPARTMENT_DETAILS_HEADER}">
+                                                               <f:param value="#{msg[departmentListController.selectedDepartment.departmentI18nKey]}" />
+                                                               <f:param value="#{departmentListController.selectedDepartment.departmentId}" />
+                                                       </h:outputFormat>
+                                               </f:facet>
+
+                                               <p:outputLabel value="#{msg.ID_HEADER}" title="#{msg.DEPARTMENT_ID_NUMBER_TITLE}" />
+                                               <h:outputText value="#{departmentListController.selectedDepartment.departmentId}" />
+                                       </p:panelGrid>
+                               </p:outputPanel>
+                       </p:dialog>
                </h:form>
 
                <h:form>
                                                        type="submit"
                                                        value="#{msg.BUTTON_ADMIN_ADD_DEPARTMENT_DATA}"
                                                        action="#{adminDepartmentController.addDepartment()}"
-                                                       update=":master:form-list-department:departmentList"
+                                                       update=":master:form-list-departments:departmentList"
                                                        />
                                        </p:panelGrid>
                                </f:facet>
index 444cbce9f5d9280144ee80c35b48e96c25640202..f56d61dc68132dd5456e36a095cdcf0b1c8080ee 100644 (file)
                                                        >
                                                        <f:converter converterId="CountryConverter" />
                                                        <f:selectItems
-                                                               value="#{countryController.allCountries()}"
+                                                               value="#{countryListController.allCountries}"
                                                                var="country"
                                                                itemValue="#{country}"
                                                                itemLabel="#{msg[country.countryI18nKey]}"