Why does @PostConstruct callback fire every time even though bean is @ViewScoped? JSF

前端 未结 5 625
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 01:19

I am using datatable on page and using binding attribute to bind it to my backing bean. This is my code :-


         


        
5条回答
  •  悲&欢浪女
    2020-11-30 01:56

    If you have a viewscoped bean and if you want to retain values that were entered on the form or don't want postconstruct fired, you should return null from your action method.

    If you return some outcome (e.g. invalid) and then point the invalid outcome to the same page using faces-config.xml, then the viewscoped bean gets recreated and thus it causes postconstruct to fire again.

提交回复
热议问题