]> git.mxchange.org Git - jjobs-war.git/blobdiff - src/java/org/mxchange/jjobs/converter/business/headquarter/JobsHeadquarterConverter.java
Don't cherry-pick:
[jjobs-war.git] / src / java / org / mxchange / jjobs / converter / business / headquarter / JobsHeadquarterConverter.java
index 0ee2ea4c6bb62122d686ef2bac5e882fc1a9d031..20de7a510b72de5e3e75bb8e33c7201e19bfdf61 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016, 2017 Roland Häder
+ * Copyright (C) 2016 - 2020 Free Software Foundation
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
@@ -24,8 +24,8 @@ import javax.faces.convert.ConverterException;
 import javax.faces.convert.FacesConverter;
 import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterNotFoundException;
 import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
-import org.mxchange.jjobs.beans.business.headquarter.JobsHeadquarterWebRequestBean;
-import org.mxchange.jjobs.beans.business.headquarter.JobsHeadquarterWebRequestController;
+import org.mxchange.jjobs.beans.business.headquarter.list.JobsHeadquarterListWebViewBean;
+import org.mxchange.jjobs.beans.business.headquarter.list.JobsHeadquarterListWebViewController;
 
 /**
  * Converter for converting company headquarter to and from id number
@@ -38,24 +38,31 @@ public class JobsHeadquarterConverter implements Converter<Headquarter> {
        /**
         * Headquarter backing bean
         */
-       private static JobsHeadquarterWebRequestController HEADQUARTER_CONTROLLER;
+       private static JobsHeadquarterListWebViewController HEADQUARTER_LIST_CONTROLLER;
 
        @Override
        public Headquarter getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
-               // Is the instance there?
-               if (null == HEADQUARTER_CONTROLLER) {
-                       HEADQUARTER_CONTROLLER = CDI.current().select(JobsHeadquarterWebRequestBean.class).get();
+               // Is the value null or empty?
+               if ((null == submittedValue) || (submittedValue.trim().isEmpty())) {
+                       // Return null
+                       return null;
                }
 
                // Init instance
                Headquarter headquarter = null;
 
+               // Is the instance there?
+               if (null == HEADQUARTER_LIST_CONTROLLER) {
+                       // Set it now
+                       HEADQUARTER_LIST_CONTROLLER = CDI.current().select(JobsHeadquarterListWebViewBean.class).get();
+               }
+
                try {
                        // Try to parse the value as long
                        final Long headquarterId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       headquarter = HEADQUARTER_CONTROLLER.findHeadquarterById(headquarterId);
+                       headquarter = HEADQUARTER_LIST_CONTROLLER.findHeadquarterById(headquarterId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);