3 Replies Latest reply on Jun 9, 2011 10:34 AM by horseface

    Where is the @Name annotation?

    horseface

      Hi,


      Im new to Seam and am trying to setup a simple project with Primefaces and Jboss 6. I've downloaded the Seam 3 Final bundle and added the jars in the artifact folder to my project. I however dont get the @Name annotation. Am i missing something?


      Thanks in advance


      /Eric

        • 1. Re: Where is the @Name annotation?
          shane.bryzak

          The @Name annotation is from Seam 2, and doesn't exist in Seam 3/CDI.  The equivalent annotation is @Named, which is defined by the CDI specification.  There is a slight difference in behaviour - the @Name annotation from Seam 2 is required to denote a class as being a Seam component, however in CDI your class is automatically a bean if it meets the requirements for a managed bean (see the managed beans specification from JSR316).

          • 2. Re: Where is the @Name annotation?
            jsoye

            Hi,
            It's actually @Named in Seam 3. In Seam 2.x it is @Name.
            @Named is in javax.inject.jar, so use it like


            import javax.inject.Named;
            
            @Named
            @SessionScoped
            public class Game implements Serializable {
               private int number;
               private int guess;
               ...
               // getters and setters
            }
            



            <h:outputText id="Higher" value="Higher!"
                              rendered="#{game.number gt game.guess and game.guess ne 0}"/>
            



            This annotation is only required when you want to make the bean accessible to a JSF view via EL (i.e., #{game}).


            The name defaults to the unqualified class name, decapitalized; in this case, game.


            In Seam 2.x, it is


            import org.jboss.seam.annotations.Name;
            
            @Name("categoryList")
            public class CategoryList {
                 ...
            }
            


            • 3. Re: Where is the @Name annotation?
              horseface

              Thanks guys, really appreaciate it.


              Regards
              /Eric