2 Replies Latest reply on Mar 16, 2006 12:12 AM by gavin.king

    beginner question - seam and MVC

    jportway

      Hi,
      I'm just evaluating Seam at the moment, and generally I'm excited by it's capabilities, but a couple of things bother me. Firstly, I may be completely wrong, but it looks as if Seam tightly couples my Session beans to JSF. The session beans in the examples, for instance, are often very JSF specific - often returning JSF result strings, for instance. Is there a way to have a traditional business logic separation so that my session beans can be used by a rich client or by web services too, or am I misunderstanding something ? I'm presuming that there is, and that the MVC separation has been compromised a bit in the examples for the sake of brevity, but it would be good to have a more strict MVC example.

      The other things that bothers me a bit is that the way a Seam component works seems to be almost entirely through what would normally be thought of as "side effects". In other words when a method is called on a seam component, often the "return value" is a context variable that gets changed in the context, rather than an explicit return value. This can make it very hard to understand what's going on. It would be really helpful for beginners like me if someone more experienced could document common Seam patterns on the Wiki, so that one could understand the underlying ideas and flow in the examples, and so that perhaps the actual example classes could be commented to show what pattern they were implementing.

        • 1. Re: beginner question - seam and MVC
          perwik

          Seam uses (can use) EJB session beans implementing a local interface for its "action components". You could just as well have a separate session bean that is just a standard EJB3 thing with all your business methods and without any seam anotations and then have your action beans look up the session bean and call its methods. This all depends on what you need. If you want to use your session beans from the outside world (desktop app) you'll have to implement a remote interface and it's not always sure that you want to have the same interfaces for local and remote anyway. I think the lack of strict layers in the examples is as you say for brevity. There's nothing in Seam that forces you to do it as it's done in the examples. And at the same time there is no law that says you need strict layers to acomplish the tasks that the example apps are there to solve.

          For your other question I'd say you just have to get used top it, you'll love it :-)

          • 2. Re: beginner question - seam and MVC
            gavin.king

            (1) Seam does not enforce any special layering on your application. If you want to layer your app as:


            JSF-aware-actions
            pure-business-logic-components
            pure-persistence-logic-DAOs

            Go ahead and do that.

            (2) If you think about it, this is how *all* web applications work. Anytime an action modifies a session or request attribute, that is a "side-effect", by your definition. (But actually, that is not the usual understanding of the word "side-effect".)