简体   繁体   English

ManagedBeans用于JSF中的不同组件

[英]ManagedBeans for different components in JSF

I have a question regarding usage of ManagedBeans in application. 我有一个关于在应用程序中使用ManagedBeans的问题。

I have a page which as different JSP components like autoComplete, selectOneMenu, textarea, inputFields, datatable etc. 我有一个页面,作为不同的JSP组件,如autoComplete,selectOneMenu,textarea,inputFields,datatable等。

I am using separate Service classes and DAO's for these components as Entity classes are different for these. 我正在为这些组件使用单独的Service类和DAO,因为Entity类对于这些类是不同的。

When it comes to ManagedBeans should I use one ManagedBean for all compoenents for one page or different ManagedBean for different components? 对于ManagedBeans,我应该为一个页面的所有组件使用一个ManagedBean,还是为不同的组件使用不同的ManagedBean?

As the components on a single page will most likely be highly coupled, there is no real benefit for using more than one managedbean. 由于单个页面上的组件很可能是高度耦合的,因此使用多个托管bean没有任何实际好处。 However if one part of the bean is highly repeated in several pages you might consider refactoring it into a Composite Component . 但是,如果bean的一部分在多个页面中高度重复,您可以考虑将其重构为复合组件

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

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