You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Alastair Rodgers (JIRA)" <de...@myfaces.apache.org> on 2007/04/05 12:34:32 UTC

[jira] Commented: (MYFACES-1165) Properties for Converters by class instead of by id

    [ https://issues.apache.org/jira/browse/MYFACES-1165?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12486912 ] 

Alastair Rodgers commented on MYFACES-1165:
-------------------------------------------

I've also been stung by this. I created a generic converter class, SelectItemConverter, which delegates to an 'adapter' managed bean to do the actual conversion (adapter is typically a session-scoped managed bean). The adapter bean's name is injected into the converter as a managed property in the faces-config.xml. The converter's getAsString() and getAsObject() methods use this to obtain the adapter bean from the FacesContext. The converter implements saveState() and restoreState() to maintain the adapter's name. 

I expected that this would allow me to register multiple converters, each with the same class (SelectItemConverter) but different IDs, and inject a different adapter name into each. However, it doesn't work because it appears that MyFaces maintains the list of converters keyed on implementation class rather than on ID. Consequently, the last registered converter of a given class wins out and the others are lost. 

I suspect that this is caused by the use of the _converterClassNameToConfigurationMap field in org.apache.myfaces.application.ApplicationImpl. This means that there can only be a single converter configuration for a given converter class name. I think the solution would be to key this map on converter ID instead of class name.

> Properties for Converters by class instead of by id
> ---------------------------------------------------
>
>                 Key: MYFACES-1165
>                 URL: https://issues.apache.org/jira/browse/MYFACES-1165
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General
>    Affects Versions: 1.1.1
>            Reporter: Bjarne Hansen
>            Priority: Minor
>
> When a converter is created it has its properties set from the configuration by converter class and not by converter id. This means that it is not possible to have different converters (id) implemented by the same class with different configurations specified in the faces configuration file.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.