7 Replies Latest reply on Mar 16, 2007 3:04 PM by pmuir

    @Factory and @DataModel on the same method

    fabricio.lemos

      Is it possible to have @Factory and @DataModel on the same method?

      At first I had this class:

      @Stateful
      @Name("displayUseCases")
      @Scope(ScopeType.EVENT)
      public class DisplayUseCasesAction implements DisplayUseCases {
      
       @EJB
       private UseCaseBsn useCaseBsn;
      
       @DataModel (scope = ScopeType.PAGE)
       private List<UseCase> useCaseList;
      
       @Factory("useCaseList")
       public void initUseCaseList() {
       useCaseList = useCaseBsn.getAll();
       }
      
       @Destroy @Remove
       public void destroy() { }
      


      But, to avoid declaring a variable that was not used, I changed it to:

      @Stateful
      @Name("displayUseCases")
      @Scope(ScopeType.EVENT)
      public class DisplayUseCasesAction implements DisplayUseCases {
      
       @EJB
       private UseCaseBsn useCaseBsn;
      
       @DataModel (scope = ScopeType.PAGE)
       @Factory("useCaseList")
       public List<UseCase> getUseCaseList() {
       return useCaseBsn.getAll();
       }
      
       @Destroy
       @Remove
       public void destroy() { }
      }
      


      After changing it, the application runs ok but I get the exception:
      20:44:31,894 WARN [Contexts] Could not destroy component: displayUseCases
      javax.ejb.EJBNoSuchObjectException: Could not find Stateful bean: a5k2v46-y6may6-ezbt3tyr-1-ezbun2fe-10

      even doing the things stated at:
      http://wiki.jboss.org/wiki/Wiki.jsp?page=JbossTimeoutSettingForSeam

      thanks in advance,
      Fabrício Lemos