]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Fri, 6 Apr 2018 21:22:45 +0000 (23:22 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 6 Apr 2018 21:22:45 +0000 (23:22 +0200)
- the helper bean needs to be view-scoped for other "list" view-scoped beans
- all action methods must return void to have JSF AJAX requests working properly
- sorted some members

Signed-off-by: Roland Häder <roland@mxchange.org>
15 files changed:
src/java/org/mxchange/jfinancials/beans/business/basicdata/FinancialsAdminBasicDataWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/business/branchoffice/FinancialsAdminBranchOfficeWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/business/department/FinancialsAdminDepartmentWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/business/employee/FinancialsAdminEmployeeWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/business/headquarter/FinancialsAdminHeadquarterWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/business/opening_time/FinancialsAdminOpeningTimeWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/country/FinancialsAdminCountryWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java [deleted file]
src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperController.java [deleted file]
src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebViewHelperBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebViewHelperController.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/mobileprovider/FinancialsAdminMobileProviderWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/phone/FinancialsAdminPhoneWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/user/FinancialsAdminUserWebRequestBean.java

index 9becdef34a08e6d03a82785853fc4432d20dd1d3..cb40dce13c9402c4a432a39a21b61fdf4ad59149 100644 (file)
@@ -152,9 +152,8 @@ public class FinancialsAdminBasicDataWebRequestBean extends BaseFinancialsBean i
        /**
         * Adds a basic business data entry, if not yet found.
         * <p>
-        * @return Redirect outcome
         */
-       public String addBusinessBasicData () {
+       public void addBusinessBasicData () {
                // First, validate all parameter
                if (this.getCompanyName() == null) {
                        // Is null
@@ -236,9 +235,6 @@ public class FinancialsAdminBasicDataWebRequestBean extends BaseFinancialsBean i
                        // Does already exist
                        throw new FacesException(e);
                }
-
-               // Continue to list again
-               return "admin_list_basic_data"; //NOI18N
        }
 
        /**
index 32e6fa40aef1058582ef90364f56f9c2570a1f94..7a809934d6745ca0894d41f49cb1fcd71549947c 100644 (file)
@@ -227,10 +227,8 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea
         * Adds branch office with all data from this backing bean. First this
         * action method will validate if the branch office's address is already
         * registered and if found, it will output a proper faces message.
-        * <p>
-        * @return Redirect outcome
         */
-       public String addBranchOffice () {
+       public void addBranchOffice () {
                // Get instance
                final BranchOffice branchOffice = this.createBranchOffice();
 
@@ -238,7 +236,7 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea
                if (this.isBranchOfficeCreatedByRequiredData(branchOffice)) {
                        // Then show proper faces message
                        this.showFacesMessage("form-admin-add-branch-office:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N
-                       return ""; //NOI18N
+                       return;
                }
 
                // Delcare updated instance
@@ -250,7 +248,7 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea
                } catch (final BranchOfficeAlreadyAddedException ex) {
                        // Output message
                        this.showFacesMessage("form-admin-add-branch-office:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N
-                       return ""; //NOI18N
+                       return;
                }
 
                // Fire event
@@ -258,9 +256,6 @@ public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBea
 
                // Clear this bean
                this.clear();
-
-               // Redirect to list
-               return "admin_list_branch_office"; //NOI18N
        }
 
        /**
index 237b24f3c536099e0cb4febbdcaf17554a5c815e..8130d2fdb36e2b711e280305498169234863da25 100644 (file)
@@ -112,10 +112,8 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean
         * Adds department with all data from this backing bean. First this action
         * method will validate if the department's address is already registered
         * and if found, it will output a proper faces message.
-        * <p>
-        * @return Redirect outcome
         */
-       public String addDepartment () {
+       public void addDepartment () {
                // Get instance
                final Department department = this.createDepartment();
 
@@ -123,7 +121,7 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean
                if (this.isDepartmentCreatedByRequiredData(department)) {
                        // Then show proper faces message
                        this.showFacesMessage("form-admin-add-department:branchStreet", "ADMIN_DEPARTMENT_ALREADY_CREATED"); //NOI18N
-                       return ""; //NOI18N
+                       return;
                }
 
                // Delcare updated instance
@@ -135,14 +133,11 @@ public class FinancialsAdminDepartmentWebRequestBean extends BaseFinancialsBean
                } catch (final DepartmentAlreadyAddedException ex) {
                        // Output message
                        this.showFacesMessage("form-admin-add-department:departmentI18nKey", "ADMIN_DEPARTMENT_ALREADY_CREATED"); //NOI18N
-                       return ""; //NOI18N
+                       return;
                }
 
                // Fire event
                this.departmentAddedEvent.fire(new DepartmentAddedEvent(updatedDepartment));
-
-               // Redirect to list
-               return "admin_list_department"; //NOI18N
        }
 
        /**
index 07bc852cd1dcb6fbbcee533d5c4daf79be010150..7da132bfbfc55667e1e1bef896b378b9a3763a23 100644 (file)
@@ -141,10 +141,8 @@ public class FinancialsAdminEmployeeWebRequestBean extends BaseFinancialsBean im
         * Adds branch office with all data from this backing bean. First this
         * action method will validate if the branch office's address is already
         * registered and if found, it will output a proper faces message.
-        * <p>
-        * @return Redirect outcome
         */
-       public String addEmployee () {
+       public void addEmployee () {
                // Get instance
                final Employable employee = this.createEmployee();
 
@@ -152,7 +150,7 @@ public class FinancialsAdminEmployeeWebRequestBean extends BaseFinancialsBean im
                if (this.isEmployeeCreatedByRequiredData(employee)) {
                        // Then show proper faces message
                        this.showFacesMessage("form-admin-add-employee:employeeNumber", "ADMIN_EMPLOYEE_ALREADY_CREATED"); //NOI18N
-                       return ""; //NOI18N
+                       return;
                }
 
                // Delcare updated instance
@@ -164,7 +162,7 @@ public class FinancialsAdminEmployeeWebRequestBean extends BaseFinancialsBean im
                } catch (final EmployeeAlreadyAddedException ex) {
                        // Output message
                        this.showFacesMessage("form-admin-add-employee:employeeNumber", "ADMIN_EMPLOYEE_ALREADY_CREATED"); //NOI18N
-                       return ""; //NOI18N
+                       return;
                }
 
                // Fire event
@@ -172,45 +170,42 @@ public class FinancialsAdminEmployeeWebRequestBean extends BaseFinancialsBean im
 
                // Clear this bean
                this.clear();
-
-               // Redirect to list
-               return "admin_list_branch_office"; //NOI18N
        }
 
        /**
-        * Getter for employee's assigned branch office
+        * Getter for employee's assigned basic company data
         * <p>
-        * @return Employee's assigned branch office
+        * @return Employee's assigned basic company data
         */
-       public BranchOffice getEmployeeBranchOffice () {
-               return this.employeeBranchOffice;
+       public BasicData getEmployeeBasicData () {
+               return this.employeeBasicData;
        }
 
        /**
-        * Setter for employee's assigned branch office
+        * Setter for employee's assigned basic company data
         * <p>
-        * @param employeeBranchOffice Employee's assigned branch office
+        * @param employeeBasicData Employee's assigned basic company data
         */
-       public void setEmployeeBranchOffice (final BranchOffice employeeBranchOffice) {
-               this.employeeBranchOffice = employeeBranchOffice;
+       public void setEmployeeBasicData (final BasicData employeeBasicData) {
+               this.employeeBasicData = employeeBasicData;
        }
 
        /**
-        * Getter for employee's assigned basic company data
+        * Getter for employee's assigned branch office
         * <p>
-        * @return Employee's assigned basic company data
+        * @return Employee's assigned branch office
         */
-       public BasicData getEmployeeBasicData () {
-               return this.employeeBasicData;
+       public BranchOffice getEmployeeBranchOffice () {
+               return this.employeeBranchOffice;
        }
 
        /**
-        * Setter for employee's assigned basic company data
+        * Setter for employee's assigned branch office
         * <p>
-        * @param employeeBasicData Employee's assigned basic company data
+        * @param employeeBranchOffice Employee's assigned branch office
         */
-       public void setEmployeeBasicData (final BasicData employeeBasicData) {
-               this.employeeBasicData = employeeBasicData;
+       public void setEmployeeBranchOffice (final BranchOffice employeeBranchOffice) {
+               this.employeeBranchOffice = employeeBranchOffice;
        }
 
        /**
index d69a8e639e8af92625d00f856b136c0f1214fa02..c15f83f0581fc0ad70daabdf3047215741f4833c 100644 (file)
@@ -216,10 +216,8 @@ public class FinancialsAdminHeadquarterWebRequestBean extends BaseFinancialsBean
         * Adds headquarter with all data from this backing bean. First this action
         * method will validate if the headquarter's address is already registered
         * and if found, it will output a proper faces message.
-        * <p>
-        * @return Redirect outcome
         */
-       public String addHeadquarter () {
+       public void addHeadquarter () {
                // Get instance
                final Headquarter headquarter = this.createHeadquarter();
 
@@ -227,7 +225,7 @@ public class FinancialsAdminHeadquarterWebRequestBean extends BaseFinancialsBean
                if (this.isHeadquarterCreatedByRequiredData(headquarter)) {
                        // Then show proper faces message
                        this.showFacesMessage("form-admin-add-headquarter-office:headquarterStreet", "ADMIN_HEADQUARTER_ALREADY_CREATED"); //NOI18N
-                       return ""; //NOI18N
+                       return;
                }
 
                // Delcare updated instance
@@ -239,7 +237,7 @@ public class FinancialsAdminHeadquarterWebRequestBean extends BaseFinancialsBean
                } catch (final HeadquarterAlreadyAddedException ex) {
                        // Output message
                        this.showFacesMessage("form-admin-add-headquarter-office:headquarterStreet", "ADMIN_HEADQUARTER_ALREADY_CREATED"); //NOI18N
-                       return ""; //NOI18N
+                       return;
                }
 
                // Fire event
@@ -247,9 +245,6 @@ public class FinancialsAdminHeadquarterWebRequestBean extends BaseFinancialsBean
 
                // Clear this bean
                this.clear();
-
-               // Redirect to list
-               return "admin_list_headquarter"; //NOI18N
        }
 
        /**
index 203c17c1e68ddefa11150d317fb0cf15c37f5bbe..c99cc9bd7124b3bc9ee4536f5bc37cf6cf36817c 100644 (file)
@@ -90,10 +90,8 @@ public class FinancialsAdminOpeningTimeWebRequestBean extends BaseFinancialsBean
         * Adds openingTime with all data from this backing bean. First this action
         * method will validate if the openingTime's address is already registered
         * and if found, it will output a proper faces message.
-        * <p>
-        * @return Redirect outcome
         */
-       public String addOpeningTimes () {
+       public void addOpeningTimes () {
                // Get instance
                final OpeningTime openingTime = this.createOpeningTimes();
 
@@ -102,9 +100,6 @@ public class FinancialsAdminOpeningTimeWebRequestBean extends BaseFinancialsBean
 
                // Fire event
                this.openingTimeAddedEvent.fire(new OpeningTimeAddedEvent(updatedOpeningTimes));
-
-               // Redirect to list
-               return "admin_list_opening_time"; //NOI18N
        }
 
        /**
index 5791012e1626310787026722e23a9cdd207bccf0..c15ca2197787e771dd9f4caca4fb075d133540d3 100644 (file)
@@ -247,10 +247,8 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp
        /**
         * Adds contact data to database and redirects on success. If the contact is
         * already found, a proper exception is thrown.
-        * <p>
-        * @return Redirect outcome
         */
-       public String addContact () {
+       public void addContact () {
                // Are all minimum fields set?
                if (this.getPersonalTitle() == null) {
                        // Throw NPE
@@ -295,9 +293,6 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp
 
                // Clear this bean
                this.clear();
-
-               // Return outcome
-               return "admin_list_contact"; //NOI18N
        }
 
        /**
@@ -486,10 +481,8 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp
 
        /**
         * Edits currently loaded contact's data in database.
-        * <p>
-        * @return Redirect outcome
         */
-       public String editContactData () {
+       public void editContactData () {
                // Get contact instance
                final Contact contact = this.createContactInstance();
 
@@ -516,9 +509,6 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsBean imp
 
                // Clear bean
                this.clear();
-
-               // Return to contact list (for now)
-               return "admin_list_contact"; //NOI18N
        }
 
        /**
index c9775bf45997ea7410f0c2b5b9962dba8260e76e..5927c9cd31c77249c9b73202e7b9f4e0d5873885 100644 (file)
@@ -109,11 +109,9 @@ public class FinancialsAdminCountryWebRequestBean extends BaseFinancialsBean imp
         * Adds country to all relevant beans and sends it to the EJB. A redirect
         * should happen after successfull creation.
         * <p>
-        * @return Redirect outcome
-        * <p>
         * @todo Add field validation
         */
-       public String addCountry () {
+       public void addCountry () {
                // Create new country object
                final Country country = new CountryData();
 
@@ -147,9 +145,6 @@ public class FinancialsAdminCountryWebRequestBean extends BaseFinancialsBean imp
 
                // Clear this bean
                this.clear();
-
-               // Redirect to list
-               return "admin_list_country"; //NOI18N
        }
 
        /**
diff --git a/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java b/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperBean.java
deleted file mode 100644 (file)
index 361cebd..0000000
+++ /dev/null
@@ -1,835 +0,0 @@
-/*
- * Copyright (C) 2016 - 2018 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.helper;
-
-import java.text.DateFormat;
-import java.text.MessageFormat;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.inject.Any;
-import javax.inject.Inject;
-import javax.inject.Named;
-import org.mxchange.jcontacts.events.contact.created.CreatedContactEvent;
-import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent;
-import org.mxchange.jcontacts.model.contact.Contact;
-import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
-import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
-import org.mxchange.jcontactsbusiness.model.department.Department;
-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.localization.FinancialsLocalizationSessionController;
-import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController;
-import org.mxchange.jfinancials.model.receipt.BillableReceipt;
-import org.mxchange.jphone.events.fax.created.CreatedFaxNumberEvent;
-import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent;
-import org.mxchange.jphone.events.landline.created.CreatedLandLineNumberEvent;
-import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent;
-import org.mxchange.jphone.events.mobile.created.CreatedMobileNumberEvent;
-import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent;
-import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jproduct.model.category.Category;
-import org.mxchange.jproduct.model.product.Product;
-import org.mxchange.jusercore.events.user.created.CreatedUserEvent;
-import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A general helper for beans
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named ("beanHelper")
-@RequestScoped
-public class FinancialsWebRequestHelperBean extends BaseFinancialsBean implements FinancialsWebRequestHelperController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 17_258_793_567_145_701L;
-
-       /**
-        * Contact instance
-        */
-       private Contact contact;
-
-       /**
-        * Event for when a contact instance was created
-        */
-       @Any
-       @Inject
-       private Event<ObservableCreatedContactEvent> contactCreatedEvent;
-
-       /**
-        * Fax number
-        */
-       private DialableFaxNumber faxNumber;
-
-       /**
-        * Event for when a fax number instance was created
-        */
-       @Any
-       @Inject
-       private Event<ObservableCreatedFaxNumberEvent> faxNumberCreatedEvent;
-
-       /**
-        * Land-line number
-        */
-       private DialableLandLineNumber landLineNumber;
-
-       /**
-        * Event for when a land-line number instance was created
-        */
-       @Any
-       @Inject
-       private Event<ObservableCreatedLandLineNumberEvent> landLineNumberCreatedEvent;
-
-       /**
-        * Localization controller
-        */
-       @Inject
-       private FinancialsLocalizationSessionController localizationController;
-
-       /**
-        * Mobile number
-        */
-       private DialableMobileNumber mobileNumber;
-
-       /**
-        * Event for when a mobile number instance was created
-        */
-       @Any
-       @Inject
-       private Event<ObservableCreatedMobileNumberEvent> mobileNumberCreatedEvent;
-
-       /**
-        * User instance
-        */
-       private User user;
-
-       /**
-        * Regular user controller
-        */
-       @Inject
-       private FinancialsUserWebRequestController userController;
-
-       /**
-        * Event for when a user instance was created
-        */
-       @Any
-       @Inject
-       private Event<ObservableCreatedUserEvent> userCreatedEvent;
-
-       /**
-        * Default constructor
-        */
-       public FinancialsWebRequestHelperBean () {
-               // Call super constructor
-               super();
-       }
-
-       /**
-        * Getter for contact instance
-        * <p>
-        * @return Contact instance
-        */
-       public Contact getContact () {
-               return this.contact;
-       }
-
-       /**
-        * Setter for contact instance
-        * <p>
-        * @param contact Contact instance
-        */
-       public void setContact (final Contact contact) {
-               this.contact = contact;
-       }
-
-       /**
-        * Returns a message key depending on if this contact is a user and/or a
-        * contact. If this contact is unused, a default key is returned.
-        * <p>
-        * @param contact Contact instance to check
-        * <p>
-        * @return Message key
-        */
-       public String getContactUsageMessageKey (final Contact contact) {
-               // The contact must be valid
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // Throw again ...
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
-               }
-
-               // Default key is "unused"
-               String messageKey = "CONTACT_IS_UNUSED"; //NOI18N
-
-               // Check user first
-               if (this.userController.isContactFound(contact)) {
-                       // Only user
-                       messageKey = "CONTACT_IS_USER"; //NOI18N
-               }
-
-               // Return message key
-               return messageKey;
-       }
-
-       /**
-        * Getter for dialable fax number
-        * <p>
-        * @return Dialable fax number
-        */
-       public DialableFaxNumber getFaxNumber () {
-               return this.faxNumber;
-       }
-
-       /**
-        * Setter for dialable fax number
-        * <p>
-        * @param faxNumber Dialable fax number
-        */
-       public void setFaxNumber (final DialableFaxNumber faxNumber) {
-               this.faxNumber = faxNumber;
-       }
-
-       /**
-        * Getter for dialable land-line number
-        * <p>
-        * @return Dialable land-line number
-        */
-       public DialableLandLineNumber getLandLineNumber () {
-               return this.landLineNumber;
-       }
-
-       /**
-        * Setter for dialable land-line number
-        * <p>
-        * @param landLineNumber Dialable land-line number
-        */
-       public void setLandLineNumber (final DialableLandLineNumber landLineNumber) {
-               this.landLineNumber = landLineNumber;
-       }
-
-       /**
-        * Getter for dialable mobile number
-        * <p>
-        * @return Dialable mobile number
-        */
-       public DialableMobileNumber getMobileNumber () {
-               return this.mobileNumber;
-       }
-
-       /**
-        * Setter for dialable mobile number
-        * <p>
-        * @param mobileNumber Dialable mobile number
-        */
-       public void setMobileNumber (final DialableMobileNumber mobileNumber) {
-               this.mobileNumber = mobileNumber;
-       }
-
-       /**
-        * Getter for user instance
-        * <p>
-        * @return User instance
-        */
-       public User getUser () {
-               return this.user;
-       }
-
-       /**
-        * Setter for user instance
-        * <p>
-        * @param user User instance
-        */
-       public void setUser (final User user) {
-               this.user = user;
-       }
-
-       /**
-        * Notifies other controllers (backing beans) if a contact id has been
-        * successfully converted to a Contact instance.
-        */
-       public void notifyControllerContactConverted () {
-               // Validate contact instance
-               if (this.getContact() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("this.contact is null"); //NOI18N
-               } else if (this.getContact().getContactId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("this.contact.contactId is null"); //NOI18N
-               } else if (this.getContact().getContactId() < 1) {
-                       // Not valid
-                       throw new IllegalStateException(MessageFormat.format("this.contact.contactId={0} is not valid.", this.getContact().getContactId())); //NOI18N
-               }
-
-               // Set all phone instances
-               this.setPhoneInstances(this.getContact());
-
-               // Set all fields: user
-               this.contactCreatedEvent.fire(new CreatedContactEvent(this.getContact()));
-       }
-
-       /**
-        * Notifies other controllers (backing beans) if a phone id has been
-        * successfully converted to a DialableFaxNumber instance.
-        */
-       public void notifyControllerFaxNumberConverted () {
-               // Validate fax instance
-               if (this.getFaxNumber() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("this.faxNumber is null"); //NOI18N
-               } else if (this.getFaxNumber().getPhoneId() == null) {
-                       // Throw again
-                       throw new NullPointerException("this.faxNumber.phoneId is null"); //NOI18N
-               } else if (this.getFaxNumber().getPhoneId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneId={0} is not valid", this.getFaxNumber().getPhoneId())); //NOI18N
-               } else if (this.getFaxNumber().getPhoneAreaCode() == null) {
-                       // Throw again
-                       throw new NullPointerException("this.faxNumber.phoneAreaCode is null"); //NOI18N
-               } else if (this.getFaxNumber().getPhoneAreaCode() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); //NOI18N
-               } else if (this.getFaxNumber().getPhoneCountry() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("this.faxNumber.phoneCountry is null"); //NOI18N
-               } else if (this.getFaxNumber().getPhoneCountry().getCountryId() == null) {
-                       // ... throw again
-                       throw new NullPointerException("this.faxNumber.phoneCountry.countryId is null"); //NOI18N
-               } else if (this.getFaxNumber().getPhoneCountry().getCountryId() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneCountry.countryId={0} is invalid", this.getFaxNumber().getPhoneCountry().getCountryId())); //NOI18N
-               } else if (this.getFaxNumber().getPhoneNumber() == null) {
-                       // Throw NPE again ...
-                       throw new NullPointerException("this.faxNumber.phoneNumber is null"); //NOI18N
-               } else if (this.getFaxNumber().getPhoneNumber() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneNumber={0} is not valid", this.getFaxNumber().getPhoneNumber())); //NOI18N
-               }
-
-               // Fire event
-               this.faxNumberCreatedEvent.fire(new CreatedFaxNumberEvent(this.getFaxNumber()));
-       }
-
-       /**
-        * Notifies other controllers (backing beans) if a phone id has been
-        * successfully converted to a DialableLandLineNumber instance.
-        */
-       public void notifyControllerLandLineNumberConverted () {
-               // Validate land-line instance
-               if (this.getLandLineNumber() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("this.landLineNumber is null"); //NOI18N
-               } else if (this.getLandLineNumber().getPhoneId() == null) {
-                       // Throw again
-                       throw new NullPointerException("this.landLineNumber.phoneId is null"); //NOI18N
-               } else if (this.getLandLineNumber().getPhoneId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneId={0} is not valid", this.getLandLineNumber().getPhoneId())); //NOI18N
-               } else if (this.getLandLineNumber().getPhoneAreaCode() == null) {
-                       // Throw again
-                       throw new NullPointerException("this.landLineNumber.phoneAreaCode is null"); //NOI18N
-               } else if (this.getLandLineNumber().getPhoneAreaCode() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); //NOI18N
-               } else if (this.getLandLineNumber().getPhoneCountry() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("this.landLineNumber.phoneCountry is null"); //NOI18N
-               } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() == null) {
-                       // ... throw again
-                       throw new NullPointerException("this.landLineNumber.phoneCountry.countryId is null"); //NOI18N
-               } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneCountry.countryId={0} is invalid", this.getLandLineNumber().getPhoneCountry().getCountryId())); //NOI18N
-               } else if (this.getLandLineNumber().getPhoneNumber() == null) {
-                       // Throw NPE again ...
-                       throw new NullPointerException("this.landLineNumber.phoneNumber is null"); //NOI18N
-               } else if (this.getLandLineNumber().getPhoneNumber() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneNumber={0} is not valid", this.getLandLineNumber().getPhoneNumber())); //NOI18N
-               }
-
-               // Fire event
-               this.landLineNumberCreatedEvent.fire(new CreatedLandLineNumberEvent(this.getLandLineNumber()));
-       }
-
-       /**
-        * Notifies other controllers (backing beans) if a phone id has been
-        * successfully converted to a DialableMobileNumber instance.
-        */
-       public void notifyControllerMobileNumberConverted () {
-               // Validate mobile instance
-               if (this.getMobileNumber() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("this.mobileNumber is null"); //NOI18N
-               } else if (this.getMobileNumber().getPhoneId() == null) {
-                       // Throw again
-                       throw new NullPointerException("this.mobileNumber.phoneId is null"); //NOI18N
-               } else if (this.getMobileNumber().getPhoneId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneId={0} is not valid", this.getMobileNumber().getPhoneId())); //NOI18N
-               } else if (this.getMobileNumber().getMobileProvider() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("this.mobileNumber.mobileProvider is null"); //NOI18N
-               } else if (this.getMobileNumber().getMobileProvider().getProviderId() == null) {
-                       // ... throw again
-                       throw new NullPointerException("this.mobileNumber.mobileProvider.providerId is null"); //NOI18N
-               } else if (this.getMobileNumber().getMobileProvider().getProviderId() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileProvider.providerId={0} is invalid", this.getMobileNumber().getMobileProvider().getProviderId())); //NOI18N
-               } else if (this.getMobileNumber().getPhoneNumber() == null) {
-                       // Throw NPE again ...
-                       throw new NullPointerException("this.mobileNumber.phoneNumber is null"); //NOI18N
-               } else if (this.getMobileNumber().getPhoneNumber() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneNumber={0} is not valid", this.getMobileNumber().getPhoneNumber())); //NOI18N
-               }
-
-               // Fire event
-               this.mobileNumberCreatedEvent.fire(new CreatedMobileNumberEvent(this.getMobileNumber()));
-       }
-
-       /**
-        * Notifies other controllers (backing beans) if a user id has been
-        * successfully converted to a User instance.
-        */
-       public void notifyControllerUserConverted () {
-               // Validate user instance
-               if (this.getUser() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("this.user is null"); //NOI18N
-               } else if (this.getUser().getUserId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("this.user.userId is null"); //NOI18N
-               } else if (this.getUser().getUserId() < 1) {
-                       // Not valid
-                       throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); //NOI18N
-               }
-
-               // Get contact
-               final Contact userContact = this.getUser().getUserContact();
-
-               // Set contact here, too. This avoids parameters that cannot auto-complete in IDEs.
-               this.setContact(userContact);
-
-               // Set all phone instances
-               this.setPhoneInstances(userContact);
-
-               // Fire event
-               this.userCreatedEvent.fire(new CreatedUserEvent(this.getUser()));
-       }
-
-       /**
-        * Renders data of basic company data
-        * <p>
-        * @param basicData Basic company data instance
-        * <p>
-        * @return Basic company data as string
-        */
-       public String renderBasicData (final BasicData basicData) {
-               // Default is empty string, so let's get started
-               final StringBuilder sb = new StringBuilder(30);
-
-               // Is basic company data set?
-               if (basicData instanceof BasicData) {
-                       // Add company name
-                       sb.append(basicData.getCompanyName()); //NOI18N
-
-                       // Is email address set?
-                       if (basicData.getCompanyEmailAddress() != null) {
-                               // Add it
-                               sb.append(", ").append(basicData.getCompanyEmailAddress()); //NOI18N
-                       }
-
-                       // Is tax number set?
-                       if (basicData.getCompanyTaxNumber() != null) {
-                               // Add it
-                               sb.append(", ").append(basicData.getCompanyTaxNumber()); //NOI18N
-                       }
-               }
-
-               // Return it
-               return sb.toString();
-       }
-
-       /**
-        * Returns the branch office's full address. If null is provided, an empty
-        * string is returned.
-        * <p>
-        * @param branchOffice Branch office instance
-        * <p>
-        * @return Branch office's address
-        */
-       public String renderBranchOffice (final BranchOffice branchOffice) {
-               // Default is empty string, so let's get started
-               final StringBuilder sb = new StringBuilder(30);
-
-               // Is a branch office instance given?
-               if (branchOffice instanceof BranchOffice) {
-                       // This should not happen:
-                       assert (branchOffice.getBranchCompany() instanceof BasicData) : "branchOffice.branchCompany is null"; //NOI18N
-
-                       // Yes, then append all data
-                       sb.append(branchOffice.getBranchCompany().getCompanyName());
-                       sb.append(", "); //NOI18N
-                       sb.append(branchOffice.getBranchStreet());
-                       sb.append(" "); //NOI18N
-                       sb.append(branchOffice.getBranchHouseNumber());
-                       sb.append(", "); //NOI18N
-                       sb.append(branchOffice.getBranchCountry().getCountryCode());
-                       sb.append(" "); //NOI18N
-                       sb.append(branchOffice.getBranchZipCode());
-                       sb.append(" "); //NOI18N
-                       sb.append(branchOffice.getBranchCity());
-               }
-
-               // Return it
-               return sb.toString();
-       }
-
-       /**
-        * Returns the contact's personal title, family name and name. If null is
-        * provided, an empty string is returned.
-        * <p>
-        * @param contact Contact instance
-        * <p>
-        * @return Contact's full name
-        */
-       public String renderContact (final Contact contact) {
-               // Default is empty string, so let's get started
-               final StringBuilder sb = new StringBuilder(20);
-
-               // Is contact set?
-               if (contact instanceof Contact) {
-                       // Then create name
-                       sb.append(this.getMessageFromBundle(contact.getContactPersonalTitle().getMessageKey()));
-                       sb.append(" "); //NOI18N
-                       sb.append(contact.getContactFirstName());
-                       sb.append(" "); //NOI18N
-                       sb.append(contact.getContactFamilyName());
-               }
-
-               // Return it
-               return sb.toString();
-       }
-
-       /**
-        * Returns the department's name and name of assigned company. If null is
-        * provided, an empty string is returned.
-        * <p>
-        * @param department Department instance
-        * <p>
-        * @return Department's full name
-        */
-       public String renderDepartment (final Department department) {
-               // Default is empty string, so let's get started
-               final StringBuilder sb = new StringBuilder(10);
-
-               // Is a department set?
-               if (department instanceof Department) {
-                       // Then create name
-                       sb.append(this.getMessageFromBundle(department.getDepartmentI18nKey()));
-                       sb.append(" ("); //NOI18N
-                       sb.append(department.getDepartmentCompany().getCompanyName());
-                       sb.append(")"); //NOI18N
-               }
-
-               // Return it
-               return sb.toString();
-       }
-
-       /**
-        * Returns the employee's number, personal title, family name and name if
-        * available. If null is provided, an empty string is returned.
-        * <p>
-        * @param employee Employable instance
-        * <p>
-        * @return Contact's full name
-        */
-       public String renderEmployee (final Employable employee) {
-               // Default is empty string, so let's get started
-               final StringBuilder sb = new StringBuilder(20);
-
-               // Is employee set?
-               if (employee instanceof Employable) {
-                       // Then create name
-                       sb.append(employee.getEmployeeNumber());
-
-                       // Is a department found?
-                       if (employee.getEmployeeDepartment() instanceof Department) {
-                               // Then add it's name to it
-                               sb.append(" ("); //NOI18N
-                               sb.append(this.renderDepartment(employee.getEmployeeDepartment()));
-                               sb.append(")"); //NOI18N
-                       }
-
-                       // Is contact data found?
-                       if (employee.getEmployeePersonalData() instanceof Contact) {
-                               // Yes, then render it
-                               final String contactName = this.renderContact(employee.getEmployeePersonalData());
-
-                               // Is it given?
-                               if (contactName != null) {
-                                       // Then add it
-                                       sb.append(" ("); //NOI18N
-                                       sb.append(contactName);
-                                       sb.append(")"); //NOI18N
-                               }
-                       }
-               }
-
-               // Return it
-               return sb.toString();
-       }
-
-       /**
-        * Returns the product name and price. If null is provided, an empty string
-        * is returned.
-        * <p>
-        * @param product Product instance
-        * <p>
-        * @return Product name
-        */
-       public String renderGenericProduct (final Product product) {
-               // Default is empty string, so let's get started
-               final StringBuilder sb = new StringBuilder(10);
-
-               // Is a product set?
-               if (product instanceof Product) {
-                       // Is product number given?
-                       if (product.getProductNumber() != null) {
-                               // Prepend it
-                               sb.append(this.getMessageFromBundle("NUMBER")).append(" "); //NOI18N
-                               sb.append(product.getProductNumber());
-                               sb.append(", "); //NOI18N
-                       }
-
-                       // Add name and price
-                       sb.append(this.getMessageFromBundle(product.getProductI18nKey()));
-
-                       // Is there any age group?
-                       if (product.getProductAgeGroup() != null) {
-                               // Show it
-                               sb.append(", ").append(this.getMessageFromBundle(product.getProductAgeGroup().getI18nKey())); //NOI18N
-                       }
-
-                       // Is there any size?
-                       if ((product.getProductSize() != null) && (!product.getProductSize().isEmpty())) {
-                               // Show size
-                               sb.append(", ").append(this.getMessageFromBundle("SIZE")).append(product.getProductSize()); //NOI18N
-                       }
-
-                       // Add price
-                       sb.append(" ("); //NOI18N
-                       sb.append(this.localizationController.formatCurrency(product.getProductGrossPrice().floatValue()));
-                       sb.append(" "); //NOI18N
-                       sb.append(product.getProductCurrencyCode());
-                       sb.append(")"); //NOI18N
-               }
-
-               // Return it
-               return sb.toString();
-       }
-
-       /**
-        * Returns the headquarter address. If null is provided, an empty string is
-        * returned.
-        * <p>
-        * @param headquarter Headquarter instance
-        * <p>
-        * @return Headquarter address
-        */
-       public String renderHeadquarter (final Headquarter headquarter) {
-               // Default is empty string, so let's get started
-               final StringBuilder sb = new StringBuilder(10);
-
-               // Is a headquarter set?
-               if (headquarter instanceof Headquarter) {
-                       // Then create name
-                       sb.append(headquarter.getHeadquarterStreet());
-                       sb.append(" "); //NOI18N
-                       sb.append(headquarter.getHeadquarterHouseNumber());
-
-                       // Is store/suite number set?
-                       if (headquarter.getHeadquarterStore() instanceof Short) {
-                               sb.append(" ("); //NOI18N
-                               sb.append(this.getMessageFromBundle("DATA_STORE")); //NOI18N
-                               sb.append(" "); //NOI18N
-                               sb.append(headquarter.getHeadquarterStore());
-                               sb.append(", "); //NOI18N
-                               sb.append(this.getMessageFromBundle("DATA_SUITE_NUMBER")); //NOI18N
-                               sb.append(" "); //NOI18N
-                               sb.append(headquarter.getHeadquarterSuiteNumber());
-                               sb.append(")"); //NOI18N
-                       }
-
-                       // Continue with country, ZIP code and city
-                       sb.append(", "); //NOI18N
-                       sb.append(headquarter.getHeadquarterCountry().getCountryCode());
-                       sb.append(" "); //NOI18N
-                       sb.append(headquarter.getHeadquarterZipCode());
-                       sb.append(" "); //NOI18N
-                       sb.append(headquarter.getHeadquarterCity());
-               }
-
-               // Return it
-               return sb.toString();
-       }
-
-       /**
-        * Returns the category's i18n string translated. If null is provided, an
-        * empty string is returned.
-        * <p>
-        * @param category Product category instance
-        * <p>
-        * @return Category's i18n string translation
-        */
-       public String renderProductCategory (final Category category) {
-               // Default is empty string, so let's get started
-               final StringBuilder sb = new StringBuilder(10);
-
-               // Is a category set?
-               if (category instanceof Category) {
-                       // Add title
-                       sb.append(this.getMessageFromBundle(category.getCategoryI18nKey()));
-
-                       // Is a parent category set?
-                       if (category.getParentCategory() instanceof Category) {
-                               // Then add it in braces, too
-                               sb.append(" ("); //NOI18N
-                               sb.append(this.getMessageFromBundle(category.getParentCategory().getCategoryI18nKey()));
-                               sb.append(")"); //NOI18N
-                       }
-               }
-
-               // Return it
-               return sb.toString();
-       }
-
-       /**
-        * Returns the receipt. If null is provided, an empty string is returned.
-        * <p>
-        * @param receipt Receipt instance
-        * <p>
-        * @return Product name
-        */
-       public String renderReceipt (final BillableReceipt receipt) {
-               // Default is empty string, so let's get started
-               final StringBuilder sb = new StringBuilder(50);
-
-               // Is receipt set?
-               if (receipt instanceof BillableReceipt) {
-                       // Add relevant data
-                       sb.append(this.getMessageFromBundle("RECEIPT_ISSUED")).append(" "); //NOI18N
-                       sb.append(DateFormat.getInstance().format(receipt.getReceiptIssued())).append(", "); //NOI18N
-                       sb.append(this.getMessageFromBundle("PAYMENT_TYPE")).append(" "); //NOI18N
-                       sb.append(this.getMessageFromBundle(receipt.getReceiptPaymentType().getI18nKey()));
-
-                       // Is receipt number included?
-                       if (receipt.getReceiptNumber() != null) {
-                               // Append it
-                               sb.append(", ").append(this.getMessageFromBundle("RECEIPT_NUMBER")).append(" "); //NOI18N
-                               sb.append(receipt.getReceiptNumber());
-                       }
-
-                       // Add company (over branch office)
-                       sb.append(" ("); //NOI18N
-                       sb.append(receipt.getReceiptBranchOffice().getBranchCompany().getCompanyName());
-                       sb.append(")"); //NOI18N
-               }
-
-               // Return it
-               return sb.toString();
-       }
-
-       /**
-        * Returns the user's personal title, family name and name. If null is
-        * provided, an empty string is returned.
-        * <p>
-        * @param user User instance
-        * <p>
-        * @return User's full name
-        */
-       public String renderUser (final User user) {
-               // Default is empty string, so let's get started
-               final StringBuilder sb = new StringBuilder(20);
-
-               // Is user given?
-               if (user instanceof User) {
-                       // Add user name first
-                       sb.append(user.getUserName());
-                       sb.append(" ("); //NOI18N
-
-                       // Add contact data
-                       sb.append(this.renderContact(user.getUserContact()));
-
-                       // Close brace
-                       sb.append(")"); //NOI18N
-               }
-
-               // Return it
-               return sb.toString();
-       }
-
-       /**
-        * Set's all given contact's phone instances: land-line, mobile and
-        * faxNumber
-        * <p>
-        * @param contact Contact to set phone instances for
-        */
-       private void setPhoneInstances (final Contact contact) {
-               // The contact must be valid
-               if (null == contact) {
-                       // Throw NPE
-                       throw new NullPointerException("contact is null"); //NOI18N
-               } else if (contact.getContactId() == null) {
-                       // Throw again ...
-                       throw new NullPointerException("contact.contactId is null"); //NOI18N
-               } else if (contact.getContactId() < 1) {
-                       // Not valid
-                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
-               }
-
-               // Is mobile set?
-               if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
-                       // Yes, then set it in admin controller
-                       this.setMobileNumber(contact.getContactMobileNumber());
-               }
-
-               // Is land-line set?
-               if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
-                       // Yes, then set it in admin controller
-                       this.setLandLineNumber(contact.getContactLandLineNumber());
-               }
-
-               // Is faxNumber set?
-               if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
-                       // Yes, then set it in admin controller
-                       this.setFaxNumber(contact.getContactFaxNumber());
-               }
-       }
-
-}
diff --git a/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperController.java b/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebRequestHelperController.java
deleted file mode 100644 (file)
index 4890ed6..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2016 - 2018 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.helper;
-
-import java.io.Serializable;
-
-/**
- * An interface for general bean helper
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface FinancialsWebRequestHelperController extends Serializable {
-
-}
diff --git a/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebViewHelperBean.java b/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebViewHelperBean.java
new file mode 100644 (file)
index 0000000..35b09af
--- /dev/null
@@ -0,0 +1,754 @@
+/*
+ * Copyright (C) 2016 - 2018 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.helper;
+
+import java.text.DateFormat;
+import java.text.MessageFormat;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.faces.view.ViewScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jcontacts.events.contact.created.CreatedContactEvent;
+import org.mxchange.jcontacts.events.contact.created.ObservableCreatedContactEvent;
+import org.mxchange.jcontacts.model.contact.Contact;
+import org.mxchange.jcontactsbusiness.model.basicdata.BasicData;
+import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
+import org.mxchange.jcontactsbusiness.model.department.Department;
+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.localization.FinancialsLocalizationSessionController;
+import org.mxchange.jfinancials.beans.user.FinancialsUserWebRequestController;
+import org.mxchange.jfinancials.model.receipt.BillableReceipt;
+import org.mxchange.jphone.events.fax.created.CreatedFaxNumberEvent;
+import org.mxchange.jphone.events.fax.created.ObservableCreatedFaxNumberEvent;
+import org.mxchange.jphone.events.landline.created.CreatedLandLineNumberEvent;
+import org.mxchange.jphone.events.landline.created.ObservableCreatedLandLineNumberEvent;
+import org.mxchange.jphone.events.mobile.created.CreatedMobileNumberEvent;
+import org.mxchange.jphone.events.mobile.created.ObservableCreatedMobileNumberEvent;
+import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
+import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
+import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
+import org.mxchange.jusercore.events.user.created.CreatedUserEvent;
+import org.mxchange.jusercore.events.user.created.ObservableCreatedUserEvent;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * A general helper for beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named ("beanHelper")
+@ViewScoped
+public class FinancialsWebViewHelperBean extends BaseFinancialsBean implements FinancialsWebViewHelperController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 17_258_793_567_145_701L;
+
+       /**
+        * Contact instance
+        */
+       private Contact contact;
+
+       /**
+        * Event for when a contact instance was created
+        */
+       @Any
+       @Inject
+       private Event<ObservableCreatedContactEvent> contactCreatedEvent;
+
+       /**
+        * Fax number
+        */
+       private DialableFaxNumber faxNumber;
+
+       /**
+        * Event for when a fax number instance was created
+        */
+       @Any
+       @Inject
+       private Event<ObservableCreatedFaxNumberEvent> faxNumberCreatedEvent;
+
+       /**
+        * Land-line number
+        */
+       private DialableLandLineNumber landLineNumber;
+
+       /**
+        * Event for when a land-line number instance was created
+        */
+       @Any
+       @Inject
+       private Event<ObservableCreatedLandLineNumberEvent> landLineNumberCreatedEvent;
+
+       /**
+        * Localization controller
+        */
+       @Inject
+       private FinancialsLocalizationSessionController localizationController;
+
+       /**
+        * Mobile number
+        */
+       private DialableMobileNumber mobileNumber;
+
+       /**
+        * Event for when a mobile number instance was created
+        */
+       @Any
+       @Inject
+       private Event<ObservableCreatedMobileNumberEvent> mobileNumberCreatedEvent;
+
+       /**
+        * User instance
+        */
+       private User user;
+
+       /**
+        * Regular user controller
+        */
+       @Inject
+       private FinancialsUserWebRequestController userController;
+
+       /**
+        * Event for when a user instance was created
+        */
+       @Any
+       @Inject
+       private Event<ObservableCreatedUserEvent> userCreatedEvent;
+
+       /**
+        * Default constructor
+        */
+       public FinancialsWebViewHelperBean () {
+               // Call super constructor
+               super();
+       }
+
+       /**
+        * Getter for contact instance
+        * <p>
+        * @return Contact instance
+        */
+       public Contact getContact () {
+               return this.contact;
+       }
+
+       /**
+        * Setter for contact instance
+        * <p>
+        * @param contact Contact instance
+        */
+       public void setContact (final Contact contact) {
+               this.contact = contact;
+       }
+
+       /**
+        * Returns a message key depending on if this contact is a user and/or a
+        * contact. If this contact is unused, a default key is returned.
+        * <p>
+        * @param contact Contact instance to check
+        * <p>
+        * @return Message key
+        */
+       public String getContactUsageMessageKey (final Contact contact) {
+               // The contact must be valid
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // Throw again ...
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
+               }
+
+               // Default key is "unused"
+               String messageKey = "CONTACT_IS_UNUSED"; //NOI18N
+
+               // Check user first
+               if (this.userController.isContactFound(contact)) {
+                       // Only user
+                       messageKey = "CONTACT_IS_USER"; //NOI18N
+               }
+
+               // Return message key
+               return messageKey;
+       }
+
+       /**
+        * Getter for dialable fax number
+        * <p>
+        * @return Dialable fax number
+        */
+       public DialableFaxNumber getFaxNumber () {
+               return this.faxNumber;
+       }
+
+       /**
+        * Setter for dialable fax number
+        * <p>
+        * @param faxNumber Dialable fax number
+        */
+       public void setFaxNumber (final DialableFaxNumber faxNumber) {
+               this.faxNumber = faxNumber;
+       }
+
+       /**
+        * Getter for dialable land-line number
+        * <p>
+        * @return Dialable land-line number
+        */
+       public DialableLandLineNumber getLandLineNumber () {
+               return this.landLineNumber;
+       }
+
+       /**
+        * Setter for dialable land-line number
+        * <p>
+        * @param landLineNumber Dialable land-line number
+        */
+       public void setLandLineNumber (final DialableLandLineNumber landLineNumber) {
+               this.landLineNumber = landLineNumber;
+       }
+
+       /**
+        * Getter for dialable mobile number
+        * <p>
+        * @return Dialable mobile number
+        */
+       public DialableMobileNumber getMobileNumber () {
+               return this.mobileNumber;
+       }
+
+       /**
+        * Setter for dialable mobile number
+        * <p>
+        * @param mobileNumber Dialable mobile number
+        */
+       public void setMobileNumber (final DialableMobileNumber mobileNumber) {
+               this.mobileNumber = mobileNumber;
+       }
+
+       /**
+        * Getter for user instance
+        * <p>
+        * @return User instance
+        */
+       public User getUser () {
+               return this.user;
+       }
+
+       /**
+        * Setter for user instance
+        * <p>
+        * @param user User instance
+        */
+       public void setUser (final User user) {
+               this.user = user;
+       }
+
+       /**
+        * Notifies other controllers (backing beans) if a contact id has been
+        * successfully converted to a Contact instance.
+        */
+       public void notifyControllerContactConverted () {
+               // Validate contact instance
+               if (this.getContact() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("this.contact is null"); //NOI18N
+               } else if (this.getContact().getContactId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("this.contact.contactId is null"); //NOI18N
+               } else if (this.getContact().getContactId() < 1) {
+                       // Not valid
+                       throw new IllegalStateException(MessageFormat.format("this.contact.contactId={0} is not valid.", this.getContact().getContactId())); //NOI18N
+               }
+
+               // Set all phone instances
+               this.setPhoneInstances(this.getContact());
+
+               // Set all fields: user
+               this.contactCreatedEvent.fire(new CreatedContactEvent(this.getContact()));
+       }
+
+       /**
+        * Notifies other controllers (backing beans) if a phone id has been
+        * successfully converted to a DialableFaxNumber instance.
+        */
+       public void notifyControllerFaxNumberConverted () {
+               // Validate fax instance
+               if (this.getFaxNumber() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("this.faxNumber is null"); //NOI18N
+               } else if (this.getFaxNumber().getPhoneId() == null) {
+                       // Throw again
+                       throw new NullPointerException("this.faxNumber.phoneId is null"); //NOI18N
+               } else if (this.getFaxNumber().getPhoneId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneId={0} is not valid", this.getFaxNumber().getPhoneId())); //NOI18N
+               } else if (this.getFaxNumber().getPhoneAreaCode() == null) {
+                       // Throw again
+                       throw new NullPointerException("this.faxNumber.phoneAreaCode is null"); //NOI18N
+               } else if (this.getFaxNumber().getPhoneAreaCode() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); //NOI18N
+               } else if (this.getFaxNumber().getPhoneCountry() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("this.faxNumber.phoneCountry is null"); //NOI18N
+               } else if (this.getFaxNumber().getPhoneCountry().getCountryId() == null) {
+                       // ... throw again
+                       throw new NullPointerException("this.faxNumber.phoneCountry.countryId is null"); //NOI18N
+               } else if (this.getFaxNumber().getPhoneCountry().getCountryId() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneCountry.countryId={0} is invalid", this.getFaxNumber().getPhoneCountry().getCountryId())); //NOI18N
+               } else if (this.getFaxNumber().getPhoneNumber() == null) {
+                       // Throw NPE again ...
+                       throw new NullPointerException("this.faxNumber.phoneNumber is null"); //NOI18N
+               } else if (this.getFaxNumber().getPhoneNumber() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("this.faxNumber.phoneNumber={0} is not valid", this.getFaxNumber().getPhoneNumber())); //NOI18N
+               }
+
+               // Fire event
+               this.faxNumberCreatedEvent.fire(new CreatedFaxNumberEvent(this.getFaxNumber()));
+       }
+
+       /**
+        * Notifies other controllers (backing beans) if a phone id has been
+        * successfully converted to a DialableLandLineNumber instance.
+        */
+       public void notifyControllerLandLineNumberConverted () {
+               // Validate land-line instance
+               if (this.getLandLineNumber() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("this.landLineNumber is null"); //NOI18N
+               } else if (this.getLandLineNumber().getPhoneId() == null) {
+                       // Throw again
+                       throw new NullPointerException("this.landLineNumber.phoneId is null"); //NOI18N
+               } else if (this.getLandLineNumber().getPhoneId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneId={0} is not valid", this.getLandLineNumber().getPhoneId())); //NOI18N
+               } else if (this.getLandLineNumber().getPhoneAreaCode() == null) {
+                       // Throw again
+                       throw new NullPointerException("this.landLineNumber.phoneAreaCode is null"); //NOI18N
+               } else if (this.getLandLineNumber().getPhoneAreaCode() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneAreaCode={0} is not valid", this.getFaxNumber().getPhoneAreaCode())); //NOI18N
+               } else if (this.getLandLineNumber().getPhoneCountry() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("this.landLineNumber.phoneCountry is null"); //NOI18N
+               } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() == null) {
+                       // ... throw again
+                       throw new NullPointerException("this.landLineNumber.phoneCountry.countryId is null"); //NOI18N
+               } else if (this.getLandLineNumber().getPhoneCountry().getCountryId() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneCountry.countryId={0} is invalid", this.getLandLineNumber().getPhoneCountry().getCountryId())); //NOI18N
+               } else if (this.getLandLineNumber().getPhoneNumber() == null) {
+                       // Throw NPE again ...
+                       throw new NullPointerException("this.landLineNumber.phoneNumber is null"); //NOI18N
+               } else if (this.getLandLineNumber().getPhoneNumber() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("this.landLineNumber.phoneNumber={0} is not valid", this.getLandLineNumber().getPhoneNumber())); //NOI18N
+               }
+
+               // Fire event
+               this.landLineNumberCreatedEvent.fire(new CreatedLandLineNumberEvent(this.getLandLineNumber()));
+       }
+
+       /**
+        * Notifies other controllers (backing beans) if a phone id has been
+        * successfully converted to a DialableMobileNumber instance.
+        */
+       public void notifyControllerMobileNumberConverted () {
+               // Validate mobile instance
+               if (this.getMobileNumber() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("this.mobileNumber is null"); //NOI18N
+               } else if (this.getMobileNumber().getPhoneId() == null) {
+                       // Throw again
+                       throw new NullPointerException("this.mobileNumber.phoneId is null"); //NOI18N
+               } else if (this.getMobileNumber().getPhoneId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneId={0} is not valid", this.getMobileNumber().getPhoneId())); //NOI18N
+               } else if (this.getMobileNumber().getMobileProvider() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("this.mobileNumber.mobileProvider is null"); //NOI18N
+               } else if (this.getMobileNumber().getMobileProvider().getProviderId() == null) {
+                       // ... throw again
+                       throw new NullPointerException("this.mobileNumber.mobileProvider.providerId is null"); //NOI18N
+               } else if (this.getMobileNumber().getMobileProvider().getProviderId() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.mobileProvider.providerId={0} is invalid", this.getMobileNumber().getMobileProvider().getProviderId())); //NOI18N
+               } else if (this.getMobileNumber().getPhoneNumber() == null) {
+                       // Throw NPE again ...
+                       throw new NullPointerException("this.mobileNumber.phoneNumber is null"); //NOI18N
+               } else if (this.getMobileNumber().getPhoneNumber() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("this.mobileNumber.phoneNumber={0} is not valid", this.getMobileNumber().getPhoneNumber())); //NOI18N
+               }
+
+               // Fire event
+               this.mobileNumberCreatedEvent.fire(new CreatedMobileNumberEvent(this.getMobileNumber()));
+       }
+
+       /**
+        * Notifies other controllers (backing beans) if a user id has been
+        * successfully converted to a User instance.
+        */
+       public void notifyControllerUserConverted () {
+               // Validate user instance
+               if (this.getUser() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("this.user is null"); //NOI18N
+               } else if (this.getUser().getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("this.user.userId is null"); //NOI18N
+               } else if (this.getUser().getUserId() < 1) {
+                       // Not valid
+                       throw new IllegalStateException(MessageFormat.format("this.user.userId={0} is not valid.", this.getUser().getUserId())); //NOI18N
+               }
+
+               // Get contact
+               final Contact userContact = this.getUser().getUserContact();
+
+               // Set contact here, too. This avoids parameters that cannot auto-complete in IDEs.
+               this.setContact(userContact);
+
+               // Set all phone instances
+               this.setPhoneInstances(userContact);
+
+               // Fire event
+               this.userCreatedEvent.fire(new CreatedUserEvent(this.getUser()));
+       }
+
+       /**
+        * Renders data of basic company data
+        * <p>
+        * @param basicData Basic company data instance
+        * <p>
+        * @return Basic company data as string
+        */
+       public String renderBasicData (final BasicData basicData) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(30);
+
+               // Is basic company data set?
+               if (basicData instanceof BasicData) {
+                       // Add company name
+                       sb.append(basicData.getCompanyName()); //NOI18N
+
+                       // Is email address set?
+                       if (basicData.getCompanyEmailAddress() != null) {
+                               // Add it
+                               sb.append(", ").append(basicData.getCompanyEmailAddress()); //NOI18N
+                       }
+
+                       // Is tax number set?
+                       if (basicData.getCompanyTaxNumber() != null) {
+                               // Add it
+                               sb.append(", ").append(basicData.getCompanyTaxNumber()); //NOI18N
+                       }
+               }
+
+               // Return it
+               return sb.toString();
+       }
+
+       /**
+        * Returns the branch office's full address. If null is provided, an empty
+        * string is returned.
+        * <p>
+        * @param branchOffice Branch office instance
+        * <p>
+        * @return Branch office's address
+        */
+       public String renderBranchOffice (final BranchOffice branchOffice) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(30);
+
+               // Is a branch office instance given?
+               if (branchOffice instanceof BranchOffice) {
+                       // This should not happen:
+                       assert (branchOffice.getBranchCompany() instanceof BasicData) : "branchOffice.branchCompany is null"; //NOI18N
+
+                       // Yes, then append all data
+                       sb.append(branchOffice.getBranchCompany().getCompanyName());
+                       sb.append(", "); //NOI18N
+                       sb.append(branchOffice.getBranchStreet());
+                       sb.append(" "); //NOI18N
+                       sb.append(branchOffice.getBranchHouseNumber());
+                       sb.append(", "); //NOI18N
+                       sb.append(branchOffice.getBranchCountry().getCountryCode());
+                       sb.append(" "); //NOI18N
+                       sb.append(branchOffice.getBranchZipCode());
+                       sb.append(" "); //NOI18N
+                       sb.append(branchOffice.getBranchCity());
+               }
+
+               // Return it
+               return sb.toString();
+       }
+
+       /**
+        * Returns the contact's personal title, family name and name. If null is
+        * provided, an empty string is returned.
+        * <p>
+        * @param contact Contact instance
+        * <p>
+        * @return Contact's full name
+        */
+       public String renderContact (final Contact contact) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(20);
+
+               // Is contact set?
+               if (contact instanceof Contact) {
+                       // Then create name
+                       sb.append(this.getMessageFromBundle(contact.getContactPersonalTitle().getMessageKey()));
+                       sb.append(" "); //NOI18N
+                       sb.append(contact.getContactFirstName());
+                       sb.append(" "); //NOI18N
+                       sb.append(contact.getContactFamilyName());
+               }
+
+               // Return it
+               return sb.toString();
+       }
+
+       /**
+        * Returns the department's name and name of assigned company. If null is
+        * provided, an empty string is returned.
+        * <p>
+        * @param department Department instance
+        * <p>
+        * @return Department's full name
+        */
+       public String renderDepartment (final Department department) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(10);
+
+               // Is a department set?
+               if (department instanceof Department) {
+                       // Then create name
+                       sb.append(this.getMessageFromBundle(department.getDepartmentI18nKey()));
+                       sb.append(" ("); //NOI18N
+                       sb.append(department.getDepartmentCompany().getCompanyName());
+                       sb.append(")"); //NOI18N
+               }
+
+               // Return it
+               return sb.toString();
+       }
+
+       /**
+        * Returns the employee's number, personal title, family name and name if
+        * available. If null is provided, an empty string is returned.
+        * <p>
+        * @param employee Employable instance
+        * <p>
+        * @return Contact's full name
+        */
+       public String renderEmployee (final Employable employee) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(20);
+
+               // Is employee set?
+               if (employee instanceof Employable) {
+                       // Then create name
+                       sb.append(employee.getEmployeeNumber());
+
+                       // Is a department found?
+                       if (employee.getEmployeeDepartment() instanceof Department) {
+                               // Then add it's name to it
+                               sb.append(" ("); //NOI18N
+                               sb.append(this.renderDepartment(employee.getEmployeeDepartment()));
+                               sb.append(")"); //NOI18N
+                       }
+
+                       // Is contact data found?
+                       if (employee.getEmployeePersonalData() instanceof Contact) {
+                               // Yes, then render it
+                               final String contactName = this.renderContact(employee.getEmployeePersonalData());
+
+                               // Is it given?
+                               if (contactName != null) {
+                                       // Then add it
+                                       sb.append(" ("); //NOI18N
+                                       sb.append(contactName);
+                                       sb.append(")"); //NOI18N
+                               }
+                       }
+               }
+
+               // Return it
+               return sb.toString();
+       }
+
+       /**
+        * Returns the headquarter address. If null is provided, an empty string is
+        * returned.
+        * <p>
+        * @param headquarter Headquarter instance
+        * <p>
+        * @return Headquarter address
+        */
+       public String renderHeadquarter (final Headquarter headquarter) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(10);
+
+               // Is a headquarter set?
+               if (headquarter instanceof Headquarter) {
+                       // Then create name
+                       sb.append(headquarter.getHeadquarterStreet());
+                       sb.append(" "); //NOI18N
+                       sb.append(headquarter.getHeadquarterHouseNumber());
+
+                       // Is store/suite number set?
+                       if (headquarter.getHeadquarterStore() instanceof Short) {
+                               sb.append(" ("); //NOI18N
+                               sb.append(this.getMessageFromBundle("DATA_STORE")); //NOI18N
+                               sb.append(" "); //NOI18N
+                               sb.append(headquarter.getHeadquarterStore());
+                               sb.append(", "); //NOI18N
+                               sb.append(this.getMessageFromBundle("DATA_SUITE_NUMBER")); //NOI18N
+                               sb.append(" "); //NOI18N
+                               sb.append(headquarter.getHeadquarterSuiteNumber());
+                               sb.append(")"); //NOI18N
+                       }
+
+                       // Continue with country, ZIP code and city
+                       sb.append(", "); //NOI18N
+                       sb.append(headquarter.getHeadquarterCountry().getCountryCode());
+                       sb.append(" "); //NOI18N
+                       sb.append(headquarter.getHeadquarterZipCode());
+                       sb.append(" "); //NOI18N
+                       sb.append(headquarter.getHeadquarterCity());
+               }
+
+               // Return it
+               return sb.toString();
+       }
+
+       /**
+        * Returns the receipt. If null is provided, an empty string is returned.
+        * <p>
+        * @param receipt Receipt instance
+        * <p>
+        * @return Product name
+        */
+       public String renderReceipt (final BillableReceipt receipt) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(50);
+
+               // Is receipt set?
+               if (receipt instanceof BillableReceipt) {
+                       // Add relevant data
+                       sb.append(this.getMessageFromBundle("RECEIPT_ISSUED")).append(" "); //NOI18N
+                       sb.append(DateFormat.getInstance().format(receipt.getReceiptIssued())).append(", "); //NOI18N
+                       sb.append(this.getMessageFromBundle("PAYMENT_TYPE")).append(" "); //NOI18N
+                       sb.append(this.getMessageFromBundle(receipt.getReceiptPaymentType().getI18nKey()));
+
+                       // Is receipt number included?
+                       if (receipt.getReceiptNumber() != null) {
+                               // Append it
+                               sb.append(", ").append(this.getMessageFromBundle("RECEIPT_NUMBER")).append(" "); //NOI18N
+                               sb.append(receipt.getReceiptNumber());
+                       }
+
+                       // Add company (over branch office)
+                       sb.append(" ("); //NOI18N
+                       sb.append(receipt.getReceiptBranchOffice().getBranchCompany().getCompanyName());
+                       sb.append(")"); //NOI18N
+               }
+
+               // Return it
+               return sb.toString();
+       }
+
+       /**
+        * Returns the user's personal title, family name and name. If null is
+        * provided, an empty string is returned.
+        * <p>
+        * @param user User instance
+        * <p>
+        * @return User's full name
+        */
+       public String renderUser (final User user) {
+               // Default is empty string, so let's get started
+               final StringBuilder sb = new StringBuilder(20);
+
+               // Is user given?
+               if (user instanceof User) {
+                       // Add user name first
+                       sb.append(user.getUserName());
+                       sb.append(" ("); //NOI18N
+
+                       // Add contact data
+                       sb.append(this.renderContact(user.getUserContact()));
+
+                       // Close brace
+                       sb.append(")"); //NOI18N
+               }
+
+               // Return it
+               return sb.toString();
+       }
+
+       /**
+        * Set's all given contact's phone instances: land-line, mobile and
+        * faxNumber
+        * <p>
+        * @param contact Contact to set phone instances for
+        */
+       private void setPhoneInstances (final Contact contact) {
+               // The contact must be valid
+               if (null == contact) {
+                       // Throw NPE
+                       throw new NullPointerException("contact is null"); //NOI18N
+               } else if (contact.getContactId() == null) {
+                       // Throw again ...
+                       throw new NullPointerException("contact.contactId is null"); //NOI18N
+               } else if (contact.getContactId() < 1) {
+                       // Not valid
+                       throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
+               }
+
+               // Is mobile set?
+               if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
+                       // Yes, then set it in admin controller
+                       this.setMobileNumber(contact.getContactMobileNumber());
+               }
+
+               // Is land-line set?
+               if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+                       // Yes, then set it in admin controller
+                       this.setLandLineNumber(contact.getContactLandLineNumber());
+               }
+
+               // Is faxNumber set?
+               if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
+                       // Yes, then set it in admin controller
+                       this.setFaxNumber(contact.getContactFaxNumber());
+               }
+       }
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebViewHelperController.java b/src/java/org/mxchange/jfinancials/beans/helper/FinancialsWebViewHelperController.java
new file mode 100644 (file)
index 0000000..f36fb12
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2016 - 2018 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.helper;
+
+import java.io.Serializable;
+
+/**
+ * An interface for general bean helper
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsWebViewHelperController extends Serializable {
+
+}
index a023a82fe36cfcd30cbe47c9bcbef82f4d6ac98d..646b6a249b2f6ca2efef4e8397c7f5759759928d 100644 (file)
@@ -101,11 +101,9 @@ public class FinancialsAdminMobileProviderWebRequestBean extends BaseFinancialsB
         * dial-prefix and country combination is done, if found, an exception is
         * thrown. A redirect should take place after successfull creation.
         * <p>
-        * @return Redirect outcome
-        * <p>
         * @todo Add field validation
         */
-       public String addMobileProvider () {
+       public void addMobileProvider () {
                // Create mobile provider instance
                final MobileProvider mobileProvider = new CellphoneProvider(this.getProviderDialPrefix(), this.getProviderName(), this.getProviderCountry(), this.getProviderMailPattern());
 
@@ -113,7 +111,7 @@ public class FinancialsAdminMobileProviderWebRequestBean extends BaseFinancialsB
                if (this.isMobileProviderCreated(mobileProvider)) {
                        // Then throw exception
                        this.showFacesMessage("form_add_mobile_provider:providerDialPrefix", new MobileProviderAlreadyAddedException(mobileProvider)); //NOI18N
-                       return ""; //NOI18N
+                       return; //NOI18N
                }
 
                // Init variable
@@ -129,9 +127,6 @@ public class FinancialsAdminMobileProviderWebRequestBean extends BaseFinancialsB
 
                // Fire event
                this.providerAddedEvent.fire(new AdminMobileProviderAddedEvent(updatedProvider));
-
-               // Redirect to list
-               return "admin_list_mobile_provider"; //NOI18N
        }
 
        /**
index 3731b3a215293fc32ae4c9a522aa4bd4ecb2fb58..caf2f9aa281bbd4b3a7372ffb78846075070824e 100644 (file)
@@ -360,9 +360,8 @@ public class FinancialsAdminPhoneWebRequestBean extends BaseFinancialsBean imple
        /**
         * Deletes given fax entry data
         * <p>
-        * @return Redirect outcome
         */
-       public String deleteFaxData () {
+       public void deleteFaxData () {
                // Get fax number from bean helper
                DialableFaxNumber number = this.createFaxNumber();
 
@@ -404,17 +403,12 @@ public class FinancialsAdminPhoneWebRequestBean extends BaseFinancialsBean imple
 
                // Fire event
                this.faxNumberDeletedEvent.fire(new AdminFaxNumberDeletedEvent(number));
-
-               // All fine, redirect
-               return "admin_list_fax"; //NOI18N
        }
 
        /**
         * Deletes given land-line entry data
-        * <p>
-        * @return Redirect outcome
         */
-       public String deleteLandLineData () {
+       public void deleteLandLineData () {
                // Get land-line number from helper
                DialableLandLineNumber number = this.createLandLineNumber();
 
@@ -456,17 +450,12 @@ public class FinancialsAdminPhoneWebRequestBean extends BaseFinancialsBean imple
 
                // Fire event
                this.landLineNumberDeletedEvent.fire(new AdminLandLineNumberDeletedEvent(number));
-
-               // All fine, redirect
-               return "admin_list_landline"; //NOI18N
        }
 
        /**
         * Deletes given mobile entry data
-        * <p>
-        * @return Redirect outcome
         */
-       public String deleteMobileData () {
+       public void deleteMobileData () {
                // Get mobile number from helper
                DialableMobileNumber number = this.createMobileNumber();
 
@@ -502,9 +491,6 @@ public class FinancialsAdminPhoneWebRequestBean extends BaseFinancialsBean imple
 
                // Fire event
                this.mobileNumberDeletedEvent.fire(new AdminMobileNumberDeletedEvent(number));
-
-               // All fine, redirect
-               return "admin_list_mobile"; //NOI18N
        }
 
        /**
index 64c40d0fce095df924897e63620d9c8059310b5b..0531fd7234c7e199a9773b728e286d3b1fa6125f 100644 (file)
@@ -216,9 +216,8 @@ public class FinancialsAdminUserWebRequestBean extends BaseFinancialsBean implem
         * sending it to the EJB. The data set in the controller is being verified,
         * e.g. if the user name or email address is not used yet.
         * <p>
-        * @return Redirect outcome
         */
-       public String addUser () {
+       public void addUser () {
                // As the form cannot validate the data (required="true"), check it here
                if (this.getUserName() == null) {
                        // Throw NPE
@@ -248,7 +247,7 @@ public class FinancialsAdminUserWebRequestBean extends BaseFinancialsBean implem
                        this.setUserPasswordRepeat(null);
 
                        // Skip it
-                       return ""; //NOI18N
+                       return;
                }
 
                try {
@@ -276,9 +275,6 @@ public class FinancialsAdminUserWebRequestBean extends BaseFinancialsBean implem
 
                // Clear this bean
                this.clear();
-
-               // Return to user list (for now)
-               return "admin_list_user"; //NOI18N
        }
 
        /**
@@ -339,10 +335,8 @@ public class FinancialsAdminUserWebRequestBean extends BaseFinancialsBean implem
 
        /**
         * Deletes given user account
-        * <p>
-        * @return Redirect outcome
         */
-       public String deleteUserData () {
+       public void deleteUserData () {
                // Is the user instance valid and CONFIRMED?
                if (this.getUser() == null) {
                        // Throw NPE
@@ -365,17 +359,12 @@ public class FinancialsAdminUserWebRequestBean extends BaseFinancialsBean implem
 
                // Fire event
                this.deleteUserEvent.fire(new AdminDeletedUserEvent(this.getUser(), this.getUserDeleteReason()));
-
-               // Redirect
-               return "admin_list_user"; //NOI18N
        }
 
        /**
         * Edits currently loaded user's data in database.
-        * <p>
-        * @return Redirect outcome
         */
-       public String editUserData () {
+       public void editUserData () {
                // Null password means not setting it
                String encryptedPassword = null;
 
@@ -402,14 +391,14 @@ public class FinancialsAdminUserWebRequestBean extends BaseFinancialsBean implem
 
                        // Not same password entered
                        this.showFacesMessage("form_edit_user:userPassword", "ADMIN_USER_PASSWORD_REPEAT_DIFFERENT"); //NOI18N
-                       return ""; //NOI18N
+                       return;
                } else if ((!Objects.equals(this.getUser().getUserName(), this.getUserName())) && (this.userBean.ifUserNameExists(this.getUserName()))) {
                        // Clear all fields
                        this.clear();
 
                        // User name already exists
                        this.showFacesMessage("form_edit_user:userName", "ADMIN_USER_NAME_ALREADY_EXISTS"); //NOI18N
-                       return ""; //NOI18N
+                       return;
                } else if (this.isSamePasswordEntered()) {
                        // Same password entered, create container
                        if ((Objects.equals(this.getUser().getUserMustChangePassword(), this.getUserMustChangePassword())) && (UserLoginUtils.ifPasswordMatches(new UserLoginContainer(this.getUser(), this.getUserPassword())))) {
@@ -419,7 +408,7 @@ public class FinancialsAdminUserWebRequestBean extends BaseFinancialsBean implem
 
                                // Same password entered
                                this.showFacesMessage("form_edit_user:userPassword", "ADMIN_USER_ENTERED_SAME_AS_OLD_PASSWORD"); //NOI18N
-                               return ""; //NOI18N
+                               return;
                        }
 
                        // Encrypt password
@@ -441,9 +430,6 @@ public class FinancialsAdminUserWebRequestBean extends BaseFinancialsBean implem
 
                // Fire event
                this.updatedUserDataEvent.fire(new AdminUpdatedUserDataEvent(updatedUser));
-
-               // Return to user list (for now)
-               return "admin_list_user"; //NOI18N
        }
 
        /**