Announcement Announcement Module
No announcement yet.
JSF integration with Spring Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JSF integration with Spring

    I've just started working with the jsf-spring stuff. I saw some posts in the spring developer mailing list archives that mentioned thoughts of integrating this into the spring framework, but the ones I saw were old. Does anyone have current thoughts on whether that's still a likely thing, or if some other direction with JSF and the Spring framwework is being discussed?

    I'd also be interested in hearing from anyone that's already used the jsf-spring stuff and how its use worked out.


  • #2
    JSF and Spring

    The JSF-Spring Library worked great for me with Sun's RI.

    In CVS, there's a native Spring DelegatingVariableResolver that you can use to get the same managed-bean to spring-bean wiring, but it throws errors with MyFaces (even though it works fine).

    I'd recommend using the JSF-Spring library as it seems to be a bit more full-featured.

    I'd be curious to see know if the native Spring resolver causes errors in Sun's RI.


    • #3
      We first developed JSF-Spring as a proposal for Spring's native JSF support but agreed with the Spring team that it would meet the needs of different developers best to continue it as a separate project and to include a more lightweight solution into Spring.

      So from version 1.1 on, Spring will feature the DelegatingVariableResolver Matt mentioned as an out-of-the-box solution for integration with JSF. As Juergen Hoeller of the Spring team stated, it "gives most of the power for typical needs: namely, access to Spring-managed middle tier beans just by referring to their bean name in JSF expressions". So what it basically provides is a link from JSF to Spring beans.

      The JSF-Spring library, on the other hand, is sort of "JSF integration for power users": It provides a more comprehensive (i.e. bidirectional) integration in that it makes Spring beans available as JSF beans and vice versa, resulting e.g. in the possibility to scope Spring beans in the same way you can scope JSF beans (application, session, and request scope).




      • #4
        Thanks for the good info. I'll take a look at the DelegatingVariableResolver class in CVS, as I'm most definitely not a "power user" of either JSF or Spring. At least not yet. As a first step all I need is a bridge between a JSF managed bean and a Spring bean. I coded something for myself that works but I don't like how it reads.

        Thanks again...


        • #5
          Re: JSF and Spring

          Originally posted by mraible
          In CVS, there's a native Spring DelegatingVariableResolver that you can use to get the same managed-bean to spring-bean wiring, but it throws errors with MyFaces (even though it works fine).

          That error message in the log is clearly something that should be changed in MyFaces: Its default VariableResolver logs that error if it can't resolve a name - despite another VariableResolver (Spring's DelegatingVariableResolver) being the caller of it...

          What DelegatingVariableResolver does is perfectly valid according to the JSF 1.1 spec. Any compliant JSF implementation should expect to see a custom VariableResolver that delegates to its original VariableResolver, assuming that the custom resolver knows further resolution strategies.

          As you say, it still works, but the error message in the log is disturbing. If you have the chance, please report this to the MyFaces people :-)



          • #6
            RE: MyFaces Warning

            Here is the response I got from the mailing list. I'll enter it as a bug to get more visibility.



            • #7
              This post may be destined for the data access forum or AOP forum, but I wanted to ask it here first in case I have a JSF-related issue. I'm using the RC2 DelegatingVariableResolver class, and as Matt indicated it works fine with the exception of MyFaces 1.0.6b complaining about not being able to resolve my spring variable, even though it's resolved ok. At form submit time, the JSF managed bean has the appropriate spring property references and also the entered values from the form. The spring bean involved implements a simple interface with one method which I invoke and that method also works just fine. The method does some SQL work using Hibernate. The datasource, Hibernate transaction manager, and related stuff all seems to work, until I turn off auto-commit in the datasource and define declarative transaction control to treat all the SQL work in the method as one logical unit of work (transaction). No matter what I seem to do with TransactionProxyFactoryBean I can't get it to recognize this method call as a target, or produce any sort of debugging output from the DebugInterceptor as a preInterceptor that I tried to configure. The SQL code that used to work still logs the same SQL statements but none of them get committed to the database. And no spring-related logging happens during this method to indicate any sort of error.

              Is there some setup/init stuff I'm missing to using the AOP transaction control support from a JSF request thread? Or is it more likely that I just have some simple definition problem in the spring context XML, web.xml, etc?

              I'd appreciate any info anyone may have, as being a newbie to Spring I'm still feeling my way around. Thanks...


              • #8
                Sorry for the previous post, I found my problem and it looks like the AOP stuff is now working....