This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

PreDestroy callback function in action controller bean?  RSS feed

Björn Wessman
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have requestScoped controller bean class with various action methods. After each of these action methods have run, I would like to invoke a "generateMessages" method. I could of course just invoke that method at the end of each action method, but was hoping for something more simple. So I looked into the @PostConstruct and @PreDestroy callback annotations. PreDestroy seemed like a perfect match for what I wanted to do, but I wasn't that lucky; The problem is that in my generateMessages method, I try to access the FacesContext, but FacesContext.getCurrentInstance() returns null at this state of the lifecycle.

Does anyone have a suggestion on how I could achieve this kind of behavior?


It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!