All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.addon.validation.ui.ValidationInputComponentEnricher Maven / Gradle / Ivy

There is a newer version: 3.10.0.Final
Show newest version
/**
 * Copyright 2013 Red Hat, Inc. and/or its affiliates.
 *
 * Licensed under the Eclipse Public License version 1.0, available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.jboss.addon.validation.ui;

import javax.inject.Inject;
import javax.validation.Validator;

import org.jboss.forge.addon.ui.input.InputComponent;
import org.jboss.forge.addon.ui.input.inject.InputComponentInjectionEnricher;
import org.jboss.forge.addon.ui.input.inject.InputComponentInjectionPoint;
import org.jboss.forge.addon.ui.validate.UIValidator;

/**
 * Enables Bean Validation 1.1 as a {@link UIValidator} object in the {@link InputComponent}
 * 
 * @author George Gastaldi
 */
public class ValidationInputComponentEnricher implements InputComponentInjectionEnricher
{
   @Inject
   private Validator validator;

   @Override
   public void enrich(InputComponentInjectionPoint injectionPoint, InputComponent input)
   {
      Class beanType = injectionPoint.getBeanClass();
      UIValidationAdapter adapter = new UIValidationAdapter(validator, input, beanType);
      input.addValidator(adapter);
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy