4 Replies Latest reply on Dec 6, 2006 12:28 PM by holgerprause

    seam jsf desgin question

      Hello,

      i just posted on the myfaces mailing list on jsf application design and package structure

      The most people the use this approach:
      1)
      The managed bean (seam component) contains the action methods for itself (explanation "course they are tied together")


      I noticed the seam example applications use a different approach
      2)
      The managed bean(seam component) is a pojo (maybe also an entity bean) and the Actions for it are seperated in 2 files - an interfaces marked local and the implementation for it


      To show some code to show the different approaches, i choose the seam registration example

      Approach 1)

      public class User implements Serializable {
       //properties
      
       //action method
       public String register();
      }
      

      ---------------------------------------------------------
      Approach 2)
      public class User implements Serializable {
       //properties
      }
      
      @Local
      public interface Register
      {
       //action method
       public String register();
      }
      
      public class RegisterAction implements Register
      {
       //action method implementation
       public String register()
       {
      
       }
      
      }
      


      So what approach should i choose (currently using approach2 but thinking about switching to 1)

      Are there any technical drawback on approach 1) ?

      Thank your very much for your help , its a very important decision i have to make(also influences the package structure).






        • 1. Re: seam jsf desgin question
          pmuir

          It's normal to split your entity (model) and action beans into different classes. You'll run into problems if you try to put the action methods on entities (e.g. Seam annotations have no effect).

          With Seam it's up to you whether you use POJOs for action beans or EJB3 Session beans.

          Or is that not what you are asking?

          • 2. Re: seam jsf desgin question

            You'll run into problems if you try to put the action methods on entities (e.g. Seam annotations have no effect).


            Oh i see, so i really have to split actions and model(entity) bean (like it is
            now)


            shouldnt this difference be reflected in your package structure or would u put all into the same package

            for example:

            1)
            de.mycompany.groups
            -Group.java //entity bean
            -ManageGroup.java //action interface
            -ManageGroupAction.java //action interface implementation

            i noticed when i put actions and beans into the same package and that package contains, lets say 6 entity classes - u will have 18 classes
            (6*3 [1 for the entity , 1 for the action interface, 1 for the action implementation]) in one singly package, its gets too huge very quick.


            Should i make a subfolder action in every package or do it this way ?

            or just like this way
            2)
            de.mycompany.model.group
            -Group.java

            de.mycompany.view.group
            -ManageGroup.java
            -ManageGroupAction.java


            or this way
            3)
            de.mycompany.group.model
            -Group.java

            de.mycompany.group.view
            -ManageGroup.java
            -ManageGroupAction.java

            or finally this way
            4)

            de.mycompany.group
            -Group.java

            de.mycompany.group.view
            -ManageGroup.java
            -ManageGroupAction.java

            waht solution would u choose ?

            I prefer 2) but i am not sure anymore, can u help please?

            Bye,
            Holger

            • 3. Re: seam jsf desgin question
              pmuir

              I use (3) but it is a personal choice :)

              • 4. Re: seam jsf desgin question

                Sigh ^^

                Well, ok that means u have

                -model
                -view

                package in every module, did i understood you right?

                I have to decide between 2 and 3, if u say solution 3) works good for you , ill adopt it.


                Thank you very much,

                Holger