Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

@FacesConverter annotation cannot set both converter-id and converter-for-class #596

@glassfishrobot

Description

@glassfishrobot

In a configuration file, you can specify BOTH a converter-id and
converter-for-class for a given converter class, for example

com.corejsf.CreditCardId com.corejsf.CreditCardConverter com.corejsf.CreditCard com.corejsf.CreditCardConverter

Trying to achieve the same effect with the @FacesConverter annotation does not work:

@FacesConverter(value="com.corejsf.CreditCardId", forClass=CreditCard.class)
public class CreditCardConverter...

The javadoc for FacesConverter accurately tell that only
Application.addConverter(java.lang.String,java.lang.String) is invoked in this
case. But this is not desirable. There is no reason not to call
Application.addConverter(java.lang.Class,java.lang.String) in addition to the
first call--they have entirely different purposes.

In particular, this makes it impossible to implement a custom converter tag that
is also an automatic converter with just using annotations.

The behavior ought to be changed to "The implementation must guarantee that for
each class annotated with FacesConverter, found with the algorithm in section
JSF.11.5, the proper variants of Application.addConverter() are called. If
converter-id is not the empty string,
Application.addConverter(java.lang.String,java.lang.String) is called, passing
the derived converter-id as the first argument and the derived converter-class
as the second argument. If forClass is not java.lang.Object.class,
Application.addConverter(java.lang.Class,java.lang.String) is called, passing
the converter-for-class as the first argument and the derived converter-class as
the second argument. The implementation must guarantee that all such calls to
addConverter() happen during application startup time and before any requests
are serviced."

Environment

Operating System: All
Platform: All

Affected Versions

[2.0]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions