6 Replies Latest reply on Sep 20, 2007 7:29 AM by vanyatka

    SessionBeans depend on JSF component libraries?

    vanyatka

      Hi,

      I've just started using RichFaces in my Seam applications and apparently SessionBeans cannot avoid referencing UI components. Is it supposed to be like this? I mean in Spring people are worried about propagating business logic into the presentation layer (Open Session in View), but here it is the other way around! From inside a SessionBean now I can manipulate UI components, collapse trees, change styles...

      And where to package those libraries? Should they go to the top level of the .ear file?

        • 1. Re: SessionBeans depend on JSF component libraries?
          pmuir

          No, SessionBeans don't depend on JSF libraries. Yes, you can bind to jsf components if you wish - but you probably shouldn't to avoid separation of concerns. You should follow seam-gen packaging.

          • 2. Re: SessionBeans depend on JSF component libraries?
            vanyatka

             

            "pete.muir@jboss.org" wrote:
            No, SessionBeans don't depend on JSF libraries. Yes, you can bind to jsf components if you wish - but you probably shouldn't to avoid separation of concerns. You should follow seam-gen packaging.


            Are they not? I'm particularly interested in using the Tree component, and according to examples I've found this is how I handle OnSelect event:

            public void onSelect (NodeSelectedEvent event) { ... }


            Are you suggesting that I should put this method into Seam POJO handlers instead of SessionBeans? One way or the other, it doesn't change the fact that the ejb.jar inside the .ear depends on RichFaces libs. To overcome this I put all richfaces libs at the top of .ear file and referenced them in META-INF/application.xml


            • 3. Re: SessionBeans depend on JSF component libraries?
              pmuir

              Well my definition of dependency is absolutely required by - here it isn't a requirement, just the way you choose to structure your app.

              1) In RichFaces 3.1 you have an api jar which contains stuff you may need to reference from your ejbs
              2) In RichFaces 3.1 you also have a xml bound tree which may not have this problem. RF also needs to provide an optional version of onSelect which doesn't take any parameters. (I'm not sure if does or not).

              • 4. Re: SessionBeans depend on JSF component libraries?
                vanyatka

                 

                "pete.muir@jboss.org" wrote:
                Well my definition of dependency is absolutely required by - here it isn't a requirement, just the way you choose to structure your app.

                Well, it is necessary as long as I want to use the component :) If you say don't use RichFaces (particularly trees, not sure about other UI components), then yes, it is not a requirement :)

                1) In RichFaces 3.1 you have an api jar which contains stuff you may need to reference from your ejbs

                Aha, that's more like it :)

                2) In RichFaces 3.1 you also have a xml bound tree which may not have this problem.

                Hm... I construct my tree from the data from DB, so I'm not quite sure this can really help me. But thanks for mentioning it anyway.

                RF also needs to provide an optional version of onSelect which doesn't take any parameters. (I'm not sure if does or not).
                

                My understanding is that some UI components require their action beans link to RF libs while others don't. Is that so?




                • 5. Re: SessionBeans depend on JSF component libraries?
                  pmuir

                   

                  "vanyatka" wrote:
                  2) In RichFaces 3.1 you also have a xml bound tree which may not have this problem.

                  Hm... I construct my tree from the data from DB, so I'm not quite sure this can really help me. But thanks for mentioning it anyway.


                  Bad language on my part - see http://in.relation.to/Bloggers/RichFaces31Released for what I meant - much better way of doing it than constructing trees in backing beans!

                  My understanding is that some UI components require their action beans link to RF libs while others don't. Is that so?


                  Yes, as few as possible is our aim (we are working on reducing this e.g. the tree design mentioned above).

                  • 6. Re: SessionBeans depend on JSF component libraries?
                    vanyatka

                     

                    "pete.muir@jboss.org" wrote:
                    Yes, as few as possible is our aim (we are working on reducing this e.g. the tree design mentioned above).

                    Thanks for your help, Pete.
                    It's all much clearer to me now. Is it too bad that I referenced RF libs in the application.xml?