/*
- * Copyright (C) 2016, 2017 Roland Häder
+ * 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 General Public License as published by
package org.mxchange.jjobs.validator.user;
import java.text.MessageFormat;
-import javax.ejb.EJB;
+import javax.enterprise.inject.spi.CDI;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.ValidatorException;
import org.mxchange.jcoreee.validator.number.BaseNumberValidator;
-import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
+import org.mxchange.jjobs.beans.user.JobsUserWebRequestBean;
+import org.mxchange.jjobs.beans.user.JobsUserWebRequestController;
/**
* A validator for user ids
public class JobsUserIdValidator extends BaseNumberValidator {
/**
- * Serial number
- */
- private static final long serialVersionUID = 12_869_569_314_764_690L;
-
- /**
- * Remote bean
+ * User backing bean
*/
- @EJB (lookup = "java:global/jfinancials-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
- private UserSessionBeanRemote userBean;
+ private static JobsUserWebRequestController USER_CONTROLLER;
/**
- * Default constructor
+ * Serial number
*/
- public JobsUserIdValidator () {
- }
+ private static final long serialVersionUID = 12_869_569_314_764_690L;
@Override
public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException {
// All accepted, required fields
- String[] requiredFields = {"userId"}; //NOI18N
+ final String[] requiredFields = {"userId"}; //NOI18N
// Pre-validation (example: not null, not a string, empty string ...)
super.preValidate(context, component, value, requiredFields, false);
+ // Is the instance there?
+ if (null == USER_CONTROLLER) {
+ // Get bean from CDI directly
+ USER_CONTROLLER = CDI.current().select(JobsUserWebRequestBean.class).get();
+ }
+
// Cast value
- Long userId = (Long) value;
+ final Long userId = (Long) value;
// Define variable
- Boolean ifUserExists = this.userBean.ifUserIdExists(userId);
+ final Boolean ifUserExists = USER_CONTROLLER.ifUserIdExists(userId);
// Is the user id valid?
if (!ifUserExists) {