2 Replies Latest reply on Aug 21, 2009 6:53 PM by brandonsimpson

    Pronlem with @Starup component

    bossy

      Hello,


      I have a problem with two of my seam components and I hope someone could point me at what might be wrong.


      Here's what I've got:




      @Name("generator")
      @Startup(depends="helper")
      @Scope(ScopeType.SESSION)
      public class Generatror implements Serializable
      {
          @In Helper helper;    
          
          public void useHelper()
          {      
            // call to helper.getMyMap()
          }
          
      }








      @Name("helper")
      @Scope(ScopeType.SESSION)
      @Startup
      public class Helper
      {
        private Map<String, myEntity> myMap=new HashMap<String, myEntity>();
        
           @Create
           public void load()
           {          
              myMap=loadMyMap();
           }
           
           public void getMyMap()
           {
              return this.MyMap;
           }     
      }







      The problem I have is that although I can see (when debugging) that the load method is being executed during startup and that myMap is populated with the values I expect,
      when it gets to the point of using that map in letterGenerator.useHelper() method myMap object is empty, as if another instance of this class was created, but the load method was not executed.


      I am, though, able to use myMap in my xhtml pages.


      Could anyone tell me what's wrong with my components?


      Thanks

        • 1. Re: Pronlem with @Starup component
          asookazian

          I have not used the depends attribute in the @Startup annotation, but I would add debug brkpts to see what's going on.  Especially in the @Create method (although I would assume that that method is only called once b/c the component is Session scoped).

          • 2. Re: Pronlem with @Starup component
            brandonsimpson

            In your code above, getMyMap() has a return type of void and also this.MyMap is used instead of this.myMap. I'm assuming you just typed those in wrong here in the post, but if not, that could be the problem. hehe


            Try putting some debug statements in your methods load(), getMyMap(), and useHelper(). Sometimes, doing that can offer a clue as to what is going wrong, like seeing calls in the wrong order, etc.