2 Replies Latest reply on Mar 22, 2007 9:07 AM by Toni Beckman

    Injecting several beans of the same type/kind/class

    Toni Beckman Novice


      is it possible to reference several entity beans of the same type from a JSF page without adding anything to the faces-config.xml?

      So that if I have the bean class EmailAddress I could simply write in my JSF page the following code:

      <h:inputText value="#{emailAddress}"/>
      <h:inputText value="#{emailAddress2}"/>
      <h:inputText value="#{emailAddress3}"/>

      I defined them in a SFSB as follows:

      public class EmailActionBean implements EmailAction
      @In(create = true)
      EntityManager entityManager;

      @In(create = true)
      EmailAddress emailAddress;

      @In(create = true)
      EmailAddress emailAddress2;

      @In(create = true)
      EmailAddress emailAddress3;

      Does seam automatically create the three instances, when the JSF page is called and even so no method of the SFSB has been invoked yet?

      I thought that the JSP page only can reference the other two entity beans, once the SFSB has been invoke in some way.

      However, the first bean seams to be always ready, because it's name matches it's class name (in bean style).