javax.faces.convert.FacesConverter Java Examples

The following examples show how to use javax.faces.convert.FacesConverter. 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: MyFacesInitializerRegistrationBean.java    From joinfaces with Apache License 2.0 6 votes vote down vote up
@Override
protected void handleScanResult(ScanResult scanResult) {
	super.handleScanResult(scanResult);

	Map<Class<? extends Annotation>, Set<Class<?>>> annotatedClasses = new HashMap<>();

	Arrays.asList(
			ManagedBean.class,
			FacesComponent.class,
			FacesBehavior.class,
			FacesConverter.class,
			NamedEvent.class,
			FacesRenderer.class,
			FacesBehaviorRenderer.class,
			FacesValidator.class
	).forEach(annotationClass -> {
		List<Class<?>> classes = scanResult.getClassesWithAnnotation(annotationClass.getName()).loadClasses();
		annotatedClasses.put(annotationClass, new HashSet<>(classes));
	});

	JoinFacesAnnotationProvider.setAnnotatedClasses(annotatedClasses);
}
 
Example #2
Source File: ConverterWrapper.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
@Override
protected Converter resolveInstanceForClass(FacesContext facesContext, Class<?> wrappedClass)
{
    FacesConverter facesConverter = wrappedClass.getAnnotation(FacesConverter.class);

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

    if (!"".equals(facesConverter.value()))
    {
        return facesContext.getApplication().createConverter(facesConverter.value());
    }

    return facesContext.getApplication().createConverter(facesConverter.forClass());
}
 
Example #3
Source File: JoinFacesAnnotationProviderTest.java    From joinfaces with Apache License 2.0 5 votes vote down vote up
@Test
public void getAnnotatedClasses_set() {
	Map<Class<? extends Annotation>, Set<Class<?>>> annotatedClasses = new HashMap<>();
	annotatedClasses.put(FacesConverter.class, new HashSet<>());
	JoinFacesAnnotationProvider.setAnnotatedClasses(annotatedClasses);

	assertThat(new JoinFacesAnnotationProvider(null).getAnnotatedClasses(null).get(FacesConverter.class))
			.isNotNull();
}