I have jsf session scoped bean. Its init method having annotation @PostConstruct is called when the page is loaded for the first time but not on every reload or refresh. I want to call some method on every page refresh. What annotation or change in xhtml file do I need to use
Try change your annotation tag as follows
Just change it to ViewScope. import javax.annotation.PostConstruct;
import javax.annotation.PostConstruct;
import javax.faces.view.ViewScoped;
import javax.inject.Named;
@Named
@ViewScoped
public class YourControllerClass implements Serializable {
@PostConstruct
public void init(){
}
}
If you want to call a method on every page refresh it 's better to use ComponentSystemEvent .
You can refer below link https://www.tutorialspoint.com/jsf/jsf_applicationevents_tag.htm
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.