0

hi I want to destroy my bean at a specific time.Is there a way that can I capture the live bean and set all of its value to NULL for instance If I have a method then I want that the bean will destroy at the end of method execution.How can I do that?

William
  • 163
  • 4
  • 18
  • You can use JSF 2.0 events. Please give more details about the "specific time' and bean scope. It seems to be a use case for Conversations scope. – Piotr Gwiazda Oct 19 '12 at 08:13
  • Is it a session-scoped bean? You can use a request-scoped bean or conversation-scoped bean. In second case you can just end conversation . Do you use JSF managed beans or CDI beans? In CDI you can annotate a method with `@Remove` annnotation. – Piotr Gwiazda Oct 19 '12 at 08:19
  • ok let me check about conservation and CDI scopes.. Because request scope didn't fulfill my requirment – William Oct 19 '12 at 09:51
  • Just use the view scope. See also http://stackoverflow.com/questions/7031885/how-to-choose-the-right-bean-scope – BalusC Oct 19 '12 at 12:06

1 Answers1

-1

Beans are available to you in different phases.If you want your processing during these phase then you can use PhaseListener for this purpose. With this interface and its method , you can get beans at different phases.Here is the detailed link about phases
Hope so it will help you.Feel free to ask if you are not clear :)

khan
  • 2,664
  • 8
  • 38
  • 64
  • where should I call this class? – William Oct 19 '12 at 10:28
  • This class will be invoked after every phase itself.You just need to register it in faces-config.xml.See the link which I posted.You will get a good detail there – khan Oct 19 '12 at 10:29