org.jboss.addon.validation.ui.ValidationInputComponentEnricher Maven / Gradle / Ivy
/**
* 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.enterprise.inject.spi.InjectionPoint;
import javax.inject.Inject;
import javax.validation.Validator;
import org.jboss.forge.addon.ui.input.InputComponent;
import org.jboss.forge.addon.ui.input.InputComponentInjectionEnricher;
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(InjectionPoint injectionPoint, InputComponent, ?> input)
{
Class> beanType = injectionPoint.getBean().getBeanClass();
UIValidationAdapter adapter = new UIValidationAdapter(validator, input, beanType);
input.addValidator(adapter);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy