3 Replies Latest reply on Mar 29, 2008 7:32 PM by pmuir

    Problem with startup data

    cremersstijn

      I have an method that is called after the initialization of seam:



      @Observer("org.jboss.seam.postInitialization")
      public void loadBasicData(){
           dropdowntypesService.retrieveDropdowntypes();
           fieldhelptextService.retrieveFie
      }



      These methods loads some data in Map that are stored in on the Application Context in the following way:



      @Name("fieldhelptextService")
      @Stateless
      public class FieldhelptextService implements IFieldhelptextService{
      
           @In
           private EntityManager entityManager;
           
           @Out(scope=ScopeType.APPLICATION)
           private Map<String, String> fieldhelptextMap = new HashMap<String, String>();
           
           public String getEjbql() {
                return "select fieldhelptexts from Fieldhelptexts fieldhelptexts";
           }
           
           
           @SuppressWarnings("unchecked")
           public void  retrieveFieldhelptext(){
                fieldhelptextMap.clear();
                Collection<Fieldhelptexts> result = entityManager.createQuery(getEjbql()).getResultList();
                for( Fieldhelptexts i : result){
                     fieldhelptextMap.put(i.getFieldname(), i.getHelptext()); 
                }
      
           }
           
      }
      



      But after accessing these methods the first time, all these Maps are empty.




        • 1. Re: Problem with startup data

          These methods loads some data in Map that are stored in on the Application Context in the following way:

          I can't see that this is an application scoped bean...


          your bean is stateless - this won't work


          what you probably want is to use a statefull bean in application scope


          @Stateful
          @Scope(ScopeType.APPLICATION)
          @Synchronized
          public class FieldhelptextService ...
          


          • 2. Re: Problem with startup data
            cremersstijn

            but when i call the method loadBasicData() from my application (with a button and an action). It works well!


            I don't want to set al my bean statefull and in the application scope, because that not good for my memory resources.

            • 3. Re: Problem with startup data
              pmuir

              Stijn Cremers wrote on Mar 27, 2008 12:43 PM:


              but when i call the method loadBasicData() from my application (with a button and an action). It works well!

              I don't want to set al my bean statefull and in the application scope, because that not good for my memory resources.


              Nonsense