Is there a way to call a method upon leaving a page with JSF or PrimeFaces?

前端 未结 4 1967
感情败类
感情败类 2021-02-20 16:48

Is there a way to call a method upon leaving a page with JSF?

4条回答
  •  感动是毒
    2021-02-20 17:17

    If you use omnifaces @ViewScoped annotation in the backing bean the bean object is destroyed when you leave the view; so you can call a function when this happens using the @PreDestroy annotation in it.

    Note: You must use omnifaces @ViewScoped annotation; with standard JSF @ViewScoped annotation the object isn't destroyed just by leaving the view, so pay attention to the import!

    Source: http://showcase.omnifaces.org/cdi/ViewScoped

提交回复
热议问题