2017  Kodetalk | Feedback | Privacy Policy | Terms | About

how to use @PostConstruct in jsf

How to use @PostConstruct in a managed bean of JSF?
How this @PostConstruct works internally?
How is it helpful?

If the bean has request scope, @PostConstruct will get executed every time.  It will be called after the managed bean is instantiated, but before the bean is placed in scope.   Such a method take no arguments, return void, and may not declare a checked exception to be thrown.  Method may be public, protected, private, or package private.  If the method throws an unchecked exception, the JSF implementation must not put the managed bean into service and no further mentioned on that managed bean instance will be called.

public TrainingClassForm() {



   public void init() {

     if (this.trainingListModel.getListDataModel() != null) {




Answer is