2 Replies Latest reply on Jun 29, 2006 11:04 PM by flo thomas

    @Factory and @Create for one method

    flo thomas Newbie

      Are there any problems if a method has a @Factory AND a @Create annotation? I need to first populate the datamodel but if I remove the @Create it "resizes" the list of the Datamodel and only has the most recent element in it, once I add another element.

      Could someone explain me in detail the @Create ?


        • 1. Re: @Factory and @Create for one method
          Jim Hazen Expert

          A description of the @Create annotation can be found in chapter 10.3 of the documentation.


          @Create only works for components that are either JavaBeans or StatefulSessionBeans and is used to denote a method that should be called when a component is created. For example if you had an init() method you wanted called before any other method on your stateful component, annotate that method with @Create.

          @Factory is used to annotate a method that creates and returns a Seam component. The value argument to @Factory will be the component's name. @Factory and @Unwrap are a lot alike. Use @Unwrap if you want your "factory" method to live in its own class. Use @Factory if you want that method to live within another component.

          Use @Create to specify an init method on a stateful component.

          Hope this helps.


          • 2. Re: @Factory and @Create for one method
            flo thomas Newbie

            But I still don't understand how the Datamodel is basically "wiped", if it was initially populated. This doesn't happen if the factory method is also annotated with @Create. The factory method does the find() for the initial population, and when I call the save() method in the same class I add the latest saved entry to the datamodel by datamodel.add(entry). I don't get how this could (again, without the Create) wipe it...