开发者

Backing Beans - which of them should be scoped?

I have two kinds of backing beans in my JSF application:

  • Managed Beans (@ManagedBean(name="bean"))
  • Entity Beans (@Entity)

Which of them should be scoped (request/session/view/application/no)?

I开发者_JAVA技巧'm having all of my managed beans scoped and entity beans not now (I had also entity beans scoped in the past and it seems to be the same as without scope). And in addition "not" could mean, that entity beans are request scoped.

Thanks for the explanation :)


The entity beans doesn't need to have a JSF managed bean scope assigned. They are supposed to be assigned as a property of a JSF managed bean. So basically, they will get the same scope as the JSF managed bean where it is been declared as a property. The JSF managed bean scope annotations works only in a @ManagedBean class. The entity beans are also not necessarily to be categorized as "backing beans". They are more "value objects".

You can see it as a further division of the "V" of the complete JSF MVC picture in another mini-MVC: the JSF managed bean is the controller, the Entity is the model and the XHTML file is the view.

See also:

  • What components are MVC in JSF MVC framework?


I would say your Managed Beans should be scoped . and not the entity beans, Thats assuming that entity beans are pojhos and all the operations are in managed Bean.

I am answering this wrt JSF v 1.1

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜