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