简体   繁体   English

支持bean应该属于多少个视图?

[英]How many views should a backing bean belong to?

I just read through this question: JSF backing bean structure (best practices) and I am trying to understand when I should make a new backing bean in my application. 我刚刚读完了这个问题: JSF支持bean结构(最佳实践) ,我试图了解何时应该在应用程序中制作新的支持bean。 If I have a view with registering a question should I then have a backing bean for that task, and another one backing bean for the editing of a question, and a third one for the view where I list all the questions and so on? 如果我有一个注册问题的视图,那么我是否应该为该任务准备一个后备bean,再为一个问题编辑一个另一个后备bean,为我列出所有问题的视图添加一个后备bean? Or, should these three views have a common backing bean? 或者,这三个视图是否应该有一个共同的后盾?

And if I have a view and a backing bean for adding a question on the admin side, can I use the same backing bean for adding a question on the user side which has its own view since they both will do the same task? 并且,如果我在管理端有一个视图和用于添加问题的支持bean,我是否可以使用相同的支持bean在具有自己视图的用户端添加一个问题,因为它们都将执行相同的任务?

Recognize that you can have combinations of extension and composition. 认识到您可以同时使用扩展名和组成。 I always try to have one backing bean per page. 我总是尝试每页有一个支持bean。 If there are common elements on multiple pages, I'd factor those out into a common utility bean - and then have that utility bean as a member of the backing beans for each page that needs it. 如果在多个页面上存在公共元素,则可以将它们分解到一个公共实用程序bean中,然后将该实用程序bean作为每个需要它的页面的支持bean的成员。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM