How to inject a Spring 3 Bean into a JSF 2 Converter?

If you want to inject beans into instances of a class, these instances have to be spring-managed. I.e. Spring has to instantiate them.

And this is not happening, so - no, you can't inject there.

If you want to inject beans into instances of a class, these instances have to be spring-managed. I.e. Spring has to instantiate them.

And this is not happening, so - no, you can't inject there. But this is because you register the converter within jsf. You can skip that: @Component("myConverter") public class MyConverter implements Converter { .. } And then, if you are using the spring : converter="#{myConverter}" So that will do it.It has worked for me.

(A workaround worth mentioning is that you can do it by using aspectj weaving and @Configurable, but I'd prefer your FacesContextUtils approach. The weaving modifies classes so that they become spring managed even if they are not instantiated by spring.).

I don't want my converter to be eligible for injection. There's a Bean called WtvrBean, and I want the bean to be injected IN the converter. I'll take a look at aspectj.

– bluefoot Feb 21 at 21:08 @bluefoot sorry, that's what I meant to say - it's not possible to inject other beans into it. – Bozho Feb 21 at 21:16 @bluefoot - oops, I forgot I had actually done this.. see my update – Bozho Feb 21 at 21:30 I don't suppose there is a way to do this with a forClass converter? – Michael Borgwardt Feb 21 at 22:03 @Michael Borgwardt not that I'm aware of.

– Bozho Feb 21 at 22:06.

Add @Scope annotation (eg with "request" parameter) to your managed bean. @ManagedBean @Scope("request") public class MyBean { .... }.

That was not what I asked. My Managed Bean is ok, just like I wrote. The problem is in the Converter.

– bluefoot Feb 21 at 20:10.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions