- java.lang.Object
-
- org.omnifaces.cdi.validator.ValidatorManager
-
@ApplicationScoped public class ValidatorManager extends Object
The
@FacesValidatoris by default not eligible for dependency injection by@Injectnor@EJB. It that only when themanaged=trueattribute is set. But this doesn't support setting custom attributes. OmniFaces solves this by implicitly making allFacesValidatorinstances eligible for dependency injection without any further modification. In order to utilize OmniFaces managed validator, simply remove the Faces nativemanaged=trueattribute.The
ValidatorManagerprovides access to allFacesValidatorannotatedValidatorinstances which are made eligible for CDI.bean-discovery-mode
Since CDI 1.1, when having a CDI 1.1 compatible
beans.xml, by default only classes with an explicit CDI managed bean scope annotation will be registered for dependency injection support. In order to coverFacesValidatorannotated classes as well, you need to explicitly setbean-discovery-mode="all"attribute inbeans.xml. This was not necessary in Mojarra versions older than 2.2.9 due to an oversight. If you want to keep the default ofbean-discovery-mode="annotated", then you need to addDependentannotation to the validator class.AmbiguousResolutionException
In case you have a
FacesValidatorannotated class extending anotherFacesValidatorannotated class which in turn extends a standard validator, then you may withbean-discovery-mode="all"face anAmbiguousResolutionException. This can be solved by placingSpecializesannotation on the subclass.JSF 2.3 compatibility
JSF 2.3 introduced two new features for validators: parameterized validators and managed validators. When the validator is parameterized as in
implements Validator<T>, then you need to use at least OmniFaces 3.1 wherein the incompatibility was fixed. When the validator is managed with themanaged=trueattribute set on theFacesValidatorannotation, then the validator won't be managed by OmniFaces and will continue to work fine for Faces. But the <o:validator> tag won't be able to set attributes on it.- Since:
- 1.6
- Author:
- Radu Creanga <rdcrng@gmail.com>, Bauke Scholtz
- See Also:
OmniApplication,OmniApplicationFactory
-
-
Constructor Summary
Constructors Constructor Description ValidatorManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ValidatorcreateValidator(Application application, String validatorId)Returns the validator instance associated with the given validator ID, ornullif there is none.
-
-
-
Method Detail
-
createValidator
public Validator createValidator(Application application, String validatorId)
Returns the validator instance associated with the given validator ID, ornullif there is none.- Parameters:
application- The involved Faces application.validatorId- The validator ID of the desired validator instance.- Returns:
- the validator instance associated with the given validator ID,
or
nullif there is none.
-
-