On 8/31/05, Mike Kienenberger <[EMAIL PROTECTED]> wrote:
Simply include a registration for the converter in one of your faces-config.xml files. The following entry will override the standard converer that is applied to any property of type Integer:
<converter>
<converter-for-class>java.lang.Integer</converter-for-class>
<converter-class>com.mycompany.MyIntegerConverter</converter-class>
</converter>
Your config files are read *after* the JSF implementation has been configured, so this *replaces* the standard one.
In other words, you want to use DI for configuring properties on a by-class converter? That, sadly, isn't supported unless you were to override the Application instance provided by your JSF impementation (or if your JSF implementation provided this feature as part of its own implementation, hint hint :-). The technique I described doesn't reference any by-id or by-type registered converters ... it creates anonymous instances.
But you don't *need* to use DI for this if your MyIntegerConverter class (see previous example) is already set up exactly the way you want it after the public zero-args constructor returns. All you need for that is the registration described above.
On 8/31/05, Craig McClanahan <[EMAIL PROTECTED]> wrote:
> If you are using by-Class converters, you don't need to register them on
> the *component* at all -- they get registered in the Application instance
> along with the class they are for. I'm not sure I see a need to use a DI
> framework to instantiate those, since you already have the ability to
> configure the implementation class that will be used.
Craig,
Can you expand on this? What do I need to do to gain the ability to
configure the implementation class?
Simply include a registration for the converter in one of your faces-config.xml files. The following entry will override the standard converer that is applied to any property of type Integer:
<converter>
<converter-for-class>java.lang.Integer</converter-for-class>
<converter-class>com.mycompany.MyIntegerConverter</converter-class>
</converter>
Your config files are read *after* the JSF implementation has been configured, so this *replaces* the standard one.
I have lots of converters registered by class, and I want to DI a
managed JSF bean into each of them. How do I do this?
In other words, you want to use DI for configuring properties on a by-class converter? That, sadly, isn't supported unless you were to override the Application instance provided by your JSF impementation (or if your JSF implementation provided this feature as part of its own implementation, hint hint :-). The technique I described doesn't reference any by-id or by-type registered converters ... it creates anonymous instances.
But you don't *need* to use DI for this if your MyIntegerConverter class (see previous example) is already set up exactly the way you want it after the public zero-args constructor returns. All you need for that is the registration described above.
-Mike
Craig

