title: JSF 2 : Accessing managed bean's instance in the phase listener object?
body: <p>Is it possible to get a reference to the to-be-executed managedbean in the before-invokeApplication-phaselistener ?</p>
  
  <p>Before the invoke application phase, it should be clear which managedBean that is going to execute the method.</p>
  
  <p>For the sake of the example, assume there's 1 main manage bean to handle 1 jsf page.</p>
  
  <p>So what i need is basically :</p>
  
  <ol>
  <li>The user access the program from the menu</li>
  <li>Because it's accessed from the menu, the main manage bean's init() method gets called to initialize stuffs like preparing data, doing authorization checks</li>
  <li>Subsequent submits dont need to call the init() method anymore until it's reaccessed from the menu</li>
  </ol>
  
  <p>To implement the point #2, im thinking of intercepting one of the phases</p>
  
  <p>I've checked the API docs about getting the managed bean in the phases implementation, but i couldnt seem to find any.</p>
  
  <p>After typing this question, i realize i could do this in @PostConstruct or the managed bean's constructor, but that would do only at the first time the bean is constructed, and my need is to call the method everytime the jsf is being accessed from the menu.</p>
  
  <p>Any suggestions ?</p>
  
  <p>Regards,<br>
  Albert Kam</p>