Exemplo n.º 1
0
  /**
   * If the {@link ConverterProvider} is present and there's a CDI managed {@link Converter}
   * instance available, then return it, else delegate to {@link #getWrapped()} which may return the
   * JSF managed {@link Converter} instance.
   */
  @Override
  public Converter createConverter(Class<?> targetClass) {
    Object provider = BeanManager.INSTANCE.getReference(ConverterProvider.class);

    if (provider
        instanceof
        ConverterProvider) { // If not null, it doesn't return true in EAR deployment on GF3, see
      // also #251.
      Converter converter =
          ((ConverterProvider) provider).createConverter(getWrapped(), targetClass);

      if (converter != null) {
        return converter;
      }
    }

    return getWrapped().createConverter(targetClass);
  }
Exemplo n.º 2
0
  /**
   * If the {@link ValidatorProvider} is present and there's a CDI managed {@link Validator}
   * instance available, then return it, else delegate to {@link #getWrapped()} which may return the
   * JSF managed {@link Validator} instance.
   */
  @Override
  public Validator createValidator(String validatorId) throws FacesException {
    Object provider = BeanManager.INSTANCE.getReference(ValidatorProvider.class);

    if (provider
        instanceof
        ValidatorProvider) { // If not null, it doesn't return true in EAR deployment on GF3, see
      // also #251.
      Validator validator =
          ((ValidatorProvider) provider).createValidator(getWrapped(), validatorId);

      if (validator != null) {
        return validator;
      }
    }

    return getWrapped().createValidator(validatorId);
  }
Exemplo n.º 3
0
 private void checkCDIAvailable() {
   try {
     BeanManager.INSTANCE.toString();
   } catch (Throwable e) {
     logger.severe(
         ""
             + "\n████████████████████████████████████████████████████████████████████████████████"
             + "\n▌                         ▐█     ▐                                             ▐"
             + "\n▌    ▄                  ▄█▓█▌    ▐ OmniFaces failed to initialize!             ▐"
             + "\n▌   ▐██▄               ▄▓░░▓▓    ▐                                             ▐"
             + "\n▌   ▐█░██▓            ▓▓░░░▓▌    ▐ This OmniFaces version requires CDI, but    ▐"
             + "\n▌   ▐█▌░▓██          █▓░░░░▓     ▐ none was found on this environment.         ▐"
             + "\n▌    ▓█▌░░▓█▄███████▄███▓░▓█     ▐                                             ▐"
             + "\n▌    ▓██▌░▓██░░░░░░░░░░▓█░▓▌     ▐ OmniFaces 2.x requires a minimum of JSF 2.2.▐"
             + "\n▌     ▓█████░░░░░░░░░░░░▓██      ▐ Since this JSF version, the JSF managed bean▐"
             + "\n▌     ▓██▓░░░░░░░░░░░░░░░▓█      ▐ facility @ManagedBean is semi-official      ▐"
             + "\n▌     ▐█▓░░░░░░█▓░░▓█░░░░▓█▌     ▐ deprecated in favour of CDI. JSF 2.2 users  ▐"
             + "\n▌     ▓█▌░▓█▓▓██▓░█▓▓▓▓▓░▓█▌     ▐ are strongly encouraged to move to CDI.     ▐"
             + "\n▌     ▓▓░▓██████▓░▓███▓▓▌░█▓     ▐                                             ▐"
             + "\n▌    ▐▓▓░█▄▐▓▌█▓░░▓█▐▓▌▄▓░██     ▐ OmniFaces goes a step further by making CDI ▐"
             + "\n▌    ▓█▓░▓█▄▄▄█▓░░▓█▄▄▄█▓░██▌    ▐ a REQUIRED dependency next to JSF 2.2. This ▐"
             + "\n▌    ▓█▌░▓█████▓░░░▓███▓▀░▓█▓    ▐ not only ensures that your web application  ▐"
             + "\n▌   ▐▓█░░░▀▓██▀░░░░░ ▀▓▀░░▓█▓    ▐ represents the state of art, but this also  ▐"
             + "\n▌   ▓██░░░░░░░░▀▄▄▄▄▀░░░░░░▓▓    ▐ makes for us easier to develop OmniFaces,   ▐"
             + "\n▌   ▓█▌░░░░░░░░░░▐▌░░░░░░░░▓▓▌   ▐ without the need for all sorts of hacks in  ▐"
             + "\n▌   ▓█░░░░░░░░░▄▀▀▀▀▄░░░░░░░█▓   ▐ in order to get OmniFaces to deploy on      ▐"
             + "\n▌  ▐█▌░░░░░░░░▀░░░░░░▀░░░░░░█▓▌  ▐ environments without CDI.                   ▐"
             + "\n▌  ▓█░░░░░░░░░░░░░░░░░░░░░░░██▓  ▐                                             ▐"
             + "\n▌  ▓█░░░░░░░░░░░░░░░░░░░░░░░▓█▓  ▐ You have 3 options:                         ▐"
             + "\n██████████████████████████████████ 1. Downgrade to OmniFaces 1.x.              ▐"
             + "\n█░▀░░░░▀█▀░░░░░░▀█░░░░░░▀█▀░░░░░▀█ 2. Install CDI in this environment.         ▐"
             + "\n█░░▐█▌░░█░░░██░░░█░░██░░░█░░░██░░█ 3. Switch to a CDI capable environment.     ▐"
             + "\n█░░▐█▌░░█░░░██░░░█░░██░░░█░░░██░░█                                             ▐"
             + "\n█░░▐█▌░░█░░░██░░░█░░░░░░▄█░░▄▄▄▄▄█ For additional instructions, check          ▐"
             + "\n█░░▐█▌░░█░░░██░░░█░░░░████░░░░░░░█ http://omnifaces.org/cdi                    ▐"
             + "\n█░░░█░░░█▄░░░░░░▄█░░░░████▄░░░░░▄█                                             ▐"
             + "\n████████████████████████████████████████████████████████████████████████████████");
     throw e;
   }
 }