javax.faces.validator.Validator Java Examples

The following examples show how to use javax.faces.validator.Validator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DateValidatorTag.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected Validator createValidator() throws JspException {
    DateValidator dateValidator = (DateValidator) super.createValidator();
    dateValidator.setFormat(getFormat());
    dateValidator.setStrict(getStrict());

    return dateValidator;
}
 
Example #2
Source File: ManagedArtifactResolver.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
public static Validator resolveManagedValidator(Class<? extends Validator> validatorClass)
{
    if (JAVAX_FACES_VALIDATOR_PACKAGE_NAME.equals(validatorClass.getPackage().getName()))
    {
        return null;
    }

    return getContextualReference(BeanManagerProvider.getInstance().getBeanManager(), validatorClass);
}
 
Example #3
Source File: InjectionAwareApplicationWrapper.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
private Validator managedOrDefaultValidator(Validator defaultResult)
{
    if (!this.containerManagedValidatorsEnabled)
    {
        return defaultResult;
    }
    if (defaultResult == null)
    {
        return null;
    }

    Validator result = ManagedArtifactResolver.resolveManagedValidator(defaultResult.getClass());

    if (result == null)
    {
        return defaultResult;
    }

    if (result instanceof DeltaSpikeProxy || ProxyUtils.isProxiedClass(result.getClass()))
    {
        return result;
    }
    else
    {
        return new ValidatorWrapper(result, this.fullStateSavingFallbackEnabled);
    }
}
 
Example #4
Source File: ValidatorWrapper.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Override
protected Validator resolveInstanceForClass(FacesContext facesContext, Class<?> wrappedClass)
{
    FacesValidator facesValidator = wrappedClass.getAnnotation(FacesValidator.class);

    if (facesValidator == null)
    {
        return null;
    }

    return facesContext.getApplication().createValidator(facesValidator.value());
}
 
Example #5
Source File: ApplicationStub.java    From development with Apache License 2.0 4 votes vote down vote up
@Override
public Validator createValidator(String arg0) throws FacesException {
    throw new UnsupportedOperationException();
}
 
Example #6
Source File: UIInputStub.java    From development with Apache License 2.0 4 votes vote down vote up
@Override
public void addValidator(Validator validator) {
    throw new UnsupportedOperationException();
}
 
Example #7
Source File: UIInputStub.java    From development with Apache License 2.0 4 votes vote down vote up
@Override
public Validator[] getValidators() {
    throw new UnsupportedOperationException();
}
 
Example #8
Source File: UIInputStub.java    From development with Apache License 2.0 4 votes vote down vote up
@Override
public void removeValidator(Validator validator) {
    throw new UnsupportedOperationException();
}
 
Example #9
Source File: XPagesDumpFactory.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
public DumpAccessor find(DumpContext dumpContext, Object o) {
    if(o instanceof ComponentParameters) {
        ComponentParameters c = (ComponentParameters)o;
        // The only access in 852 is through JSON
        try {
            JsonObject js = (JsonObject)JsonParser.fromJson(JsonJavaFactory.instanceEx,c.getAsJson());
            return new JavaScriptDumpFactory.Json(dumpContext,JsonJavaFactory.instanceEx,js);
        } catch(Throwable t) {
            return new JavaDumpFactory.ExceptionValue(dumpContext,t);
        }
    }
    // Use of JSF registry
	if(USE_JSF_REGISTRY) {
        if(    (o instanceof UIComponent) 
        	|| (o instanceof Converter)
        	|| (o instanceof Validator)
        	|| (o instanceof ValueBindingObject)) {
        	FacesDefinition def = XPagesDumpFactory.findDefinition(dumpContext, o);
        	if(def!=null) {
            	return new JSFRegistryValueMap(dumpContext, def, o);
        	}
        }
	}
	// Regular component as a bean
    if(o instanceof UIComponent) {
		return JavaDumpFactory.createJavaBean(dumpContext, o, new JavaDumpFactory.JavaBean.IFilter() {
			public boolean accept(PropertyDescriptor desc) {
				return true;
			}
		});
    }
    if(o instanceof HttpServletRequest) {
        return new HttpServletRequestMap(dumpContext,(HttpServletRequest)o);
    }
    if(o instanceof HttpSession) {
        return new HttpSessionMap(dumpContext,(HttpSession)o);
    }
    if(o instanceof Cookie) {
        return new CookieMap(dumpContext,(Cookie)o);
    }
    if(o instanceof SessionData) {
        return new SessionDataMap(dumpContext,(SessionData)o);
    }
    return null;
}
 
Example #10
Source File: RegexValidatorTag.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected Validator createValidator() throws JspException {
    RegexValidator result = (RegexValidator) super.createValidator();
    result.setRegex(regex);
    return result;
}
 
Example #11
Source File: ConverterAndValidatorProxyExtension.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("UnusedDeclaration")
public <X> void findConverterAndValidatorsWhichNeedProxiesForDependencyInjectionSupport(
        @Observes ProcessAnnotatedType<X> pat, BeanManager beanManager)
{
    if (!this.isActivated)
    {
        return;
    }

    Class<X> beanClass = pat.getAnnotatedType().getJavaClass();

    if (!(Converter.class.isAssignableFrom(beanClass) || (Validator.class.isAssignableFrom(beanClass))))
    {
        return;
    }

    Bean<X> bean = new BeanBuilder<X>(beanManager).readFromType(pat.getAnnotatedType()).create();
    // veto normal converters/validators -> they will get excluded from the special handling later on
    if (!hasInjectionPoints(bean) && !hasNormalScopeAnnotation(bean, beanManager))
    {
        pat.veto();
        return;
    }

    // converters/validators without properties for tags, will be handled by the corresponding manual wrapper
    if (!hasPublicProperty(beanClass))
    {
        return;
    }

    if (!(Modifier.isFinal(beanClass.getModifiers())))
    {
        this.classesToProxy.add(beanClass);
        pat.veto();
    }
    else
    {
        LOG.warning("To use dependency-injection in converters/validators with properties, " +
                "you they aren't allowed to be 'final'.");
    }
}
 
Example #12
Source File: InjectionAwareApplicationWrapper.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@Override
public Validator createValidator(String validatorId) throws FacesException
{
    return managedOrDefaultValidator(this.wrapped.createValidator(validatorId));
}
 
Example #13
Source File: ValidatorWrapper.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public ValidatorWrapper(Validator wrapped, boolean fullStateSavingFallbackEnabled)
{
    super(wrapped, fullStateSavingFallbackEnabled);
}