Backing beans (@ManagedBean) or CDI Beans (@Named)?

后端 未结 5 1800
南旧
南旧 2020-11-22 00:33

I\'ve just started reading through Core JavaServer Faces, 3rd Ed. and they say this (emphasis mine):

It is a historical accident that there are two se

5条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 00:57

    One good reason to move to CDI: you could have a common session-scoped resource (user profile for example) @Inject'ed into both JSF managed beans and REST services (i.e., Jersey/JAX-RS).

    On the other hand, @ViewScoped is a compelling reason to stick with JSF @ManagedBean - especially for anything with significant AJAX. There is no standard replacement for this in CDI.

    Seems that it may have some support for a @ViewScoped-like annotation for CDI beans, but I haven't played with it personally.

    http://seamframework.org/Seam3/FacesModule

提交回复
热议问题