Announcement Announcement Module
Collapse
No announcement yet.
Injection into jsf managed beans Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Injection into jsf managed beans

    Hello dear spring developers. Could you please help me to find way to inject spring beans into jsf managed beans? In the spring reference i found the way to get beans like this:

    ApplicationContext ctx = FacesContextUtils.getWebApplicationContext(FacesCo ntext.getCurrentInstance());
    Test test = (Test) ctx.getBean("test");

    I don't think that there is good way. Web framework wicket, for example, used the annotation "SpringBean" to inject the beans.

    Do you know about some library that works with jsf and spring ?
    I am using jsf 1.2 and spring 2.5

    Regards,
    Dima

  • #2
    May be it's trivial, but I don't find the answer. Can you help me?

    Comment


    • #3
      You donīt need managed beans. You have to configure your faces-config to use spring el resolver. In that way, your spring beans (you can annotate them just with @Component) will be available in JSF pages. The advantage of this aproach is that you donīt have to take care of your faces-config.xml. The magic is done by spring el resolver in faces-config. I am using in that way and finding it a very elegant solution.

      Comment


      • #4
        Thank you Bosnic, I haven't heard about this approach. It woluld be very usefull. But how could you solve the problem of navigation without faces-config.xml? Do you have some example of code, using this approach? Thanks a lot.

        Comment

        Working...
        X