1 Reply Latest reply on Feb 15, 2011 11:16 AM by alesj

    What if beans that are outjected by Producer changes

    yangju.richard.yang.pearson.com
      For example I have a session scoped producer in my jsf controller bean:
      @Named
      @SessionScoped

      Class Test{
      @Inject
          private MyService myService;

      @Produces
          @SessionScoped
          @Named
          public List<MyEntity> getEntities() {
              return myService.getEntities();

          }
      }

      I use producer here to outject List<MyEntity> so that it can be injected into other beans. However, myService.getEntities() returns different list based on user selections. Therefore the myService.getEntities()'s return value changes. My understanding of producer is that it is only call myService.getEntities() once, then the producer will never call myService.getEntities() again.

      How do I change the what the producer outjected list? I mean when the end user selects a different parameter in the web page, I need to adjust the getEntities that is outjected?

      I guess @Observer won't work in this case, as the myService.getEntities() is only called once no matter what? What if myService.getEntities()return null, will it be called again?