2 Replies Latest reply on Mar 4, 2008 10:46 PM by Nicklas Karlsson

    Beginner: some questions

    Stefan Weber Newbie

      Hello,
      i am totally new to Seam and JSF and after playing around with, reading the reference (well at least parts of it) and the book JBoss Seam from Michael Yuan and Thomas Heute iam totally confused and stuck with all kinds of errors


      My first Question is, how do the entity bean, session bean and jsf page relate to each other. I have an annotated entity bean with @Name(contact) and AutoCreate. I have a session bean with @In private Contact contact. In my JSF i use contact.property. What does it relate to ? the entity or the injected contact in the session bean ? i tried to use another name withing my session bean private Contact newcontact but got alot of error messages then.


      Also if i leave out the AutoCreate i get a null value exception ?


      I hope someone could explain me in easy words ;-)


      Thank you,


      Stefan 

        • 1. Re: Beginner: some questions
          Damian Harvey Apprentice

          While the Seam book is good you may find the Reference Documentation as helpful (a second source of info is always a good thing).


          EntityBean : think of this as being a record from your database. You should start off by not putting any logic in it at all. It's just a container.


          SessionBean : this is where you might have some logic, eg. reading a record from the database into an EntityBean.


          JSF Page : the page that you present to the User. You can refer to your Session bean with the notation #{mySessionBeanName.someProperty}



          AutoCreate just tells Seam to create an instance of the Bean automatically. Rather than having to use @In(create=true) you can just use @In. If you are getting null pointers then you'll need either @AutoCreate or @In(create=true)


          I really would suggest using Seam-Gen to create your first project. If you follow the standards from that you'll see how EntityBeans get created (they don't have @Name - although there's non reason why not).


          You got error messages when you tried to use newcontact because the name of the variable used with @In should match exactly the name you provide with @Name (unless you use @In(value="#{contact}") Contact newContact;


          Give Seam-gen a go and then let us know how you get on.


          Cheers,


          Damian

          • 2. Re: Beginner: some questions
            Nicklas Karlsson Master

            The JBoss Tools for Eclipse have a great wizard for creating new projects, too.


            If you are new to MVC and IOC-frameworks, reading through a book at one sitting might be a little like trying to drink from a fire hose. Play around with code. Then re-read the manual. Test theories in code. Re-read the manual.


            There is a nice article series on IBM developerWorks Java section, too.