1 Reply Latest reply on Nov 30, 2006 6:12 PM by Norman Richards

    ScopeType.EVENT versus getter method actionBean.getProperty(

    anti spart Newbie

      Am I correct in my understanding that the following two are effectively the same? the property is outjected into event scope so it's called several times during the JSF request processing lifecyle, and so is the the actionBean.getProperty() method - and both have the same lifetimes?

      ActionBean.java:
      
      @Stateful
      @Name("actionBean")
      public class ActionBean implements ActionBeanLocal (
      ....
      public getProperty()
       return property();
      }
      
      ...
      
      example.xhtml:
      
      <h:outputText value="#{actionBean.getProperty}"/>


      and

      ActionBean.java:
      
      @Stateful
      @Name("actionBean")
      public class ActionBean implements ActionBeanLocal (
      ....
      @Out(scope=ScopeType.EVENT)
      public getProperty()
       return property();
      }
      
      ...
      
      example.xhtml:
      
      <h:outputText value="#{property}"/>


      When is one pattern preferable to the other?

        • 1. Re: ScopeType.EVENT versus getter method actionBean.getPrope
          Norman Richards Master

          That should be #{actionBean.property}.

          One difference between the two is that in the second example, #{property} only will be defined when an action is invoked on actionBean. (you can solve this with a page action or factory annotation)


          On the question of which is better, a good first question to ask yourself is: Is X a standalone concept or is it just a property of a component. If X has no meaning outside of your component, outjecting doesn't seem to serve any purpose.