[
https://issues.apache.org/jira/browse/MYFACES-4311?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16980202#comment-16980202
]
Volodymyr Siedlecki commented on MYFACES-4311:
----------------------------------------------
I also had the same question about the order. I was going to mention standard
converters but I realized those aren’t touched by CDI. If you go so far to make
your own convertor and make it CDI managed then it’s more likely that you’ll
generics? It’s better practice, too, I suppose? In that sense, it would be
better to check for the type first.
I’ve updated the patches to check the type and included one for validator, too.
I’ll try to get to the unit tests next.
> Custom Converters Do Not Support Generics
> -----------------------------------------
>
> Key: MYFACES-4311
> URL: https://issues.apache.org/jira/browse/MYFACES-4311
> Project: MyFaces Core
> Issue Type: Bug
> Components: JSR-372
> Affects Versions: 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5
> Reporter: Volodymyr Siedlecki
> Priority: Minor
> Attachments: ConverterTestApp.war, MYFACES-4311.patch,
> updated_MYFACES-4311.patch
>
>
> Hello,
>
> A user posted an issue with the Converter's here:
> [https://stackoverflow.com/questions/58825333/facesconverter-is-null-jsf-2-3-cdi-2-0]
>
> I investigated the issue, and it is caused by the beanManger#getBeans inside
> the /org/apache/myfaces/cdi/util/CDIUtils.java file. The getBeans returns an
> empty set instead of the converter bean. It searches by class, but it should
> also check by type. Since it's an problem with MyFaces code, I thought I'd
> open an issue here.
>
> I've provided a patch (overloading the CDIUtil.java methods to accept a type)
> and sample app (borrowed from StackOverflow).
>
> I only modified the code to search by type (1) when using getBeans. Type is
> obtained from creating a TypeLiteral (2).
>
> Since Validators don't check by type as Converters, I can make another fix if
> you don't have any issues with this patch.
> Please let me know if you have questions or suggestions for the code.
>
> 1)
> https://javaee.github.io/javaee-spec/javadocs/javax/enterprise/inject/spi/BeanManager.html#getBeans-java.lang.reflect.Type-java.lang.annotation.Annotation...-
> 2)
> https://javaee.github.io/javaee-spec/javadocs/javax/enterprise/util/TypeLiteral.html
--
This message was sent by Atlassian Jira
(v8.3.4#803005)