JSF MVC框架中的MVC有哪些组件? [英] What components are MVC in JSF MVC framework?
问题描述
在JSF MVC框架中是Model,View和Controller?
这取决于观点(双关语
在大型建筑图片中,您自己的JSF代码是 V :
M - 业务域/服务层(例如EJB / JPA / DAO)
V - 您的JSF代码
C - FacesServlet
在开发人员图片中,架构 V 可分为以下几种: / p>
M - 实体
V - Facelets / JSP页面
C - 受管Bean
在较小的客户端图片中,开发人员 V 可分为以下几种:
M - JSF组件树
V - 渲染的HTML输出
C - 客户端(webbrowser)
在较小的Java脚本图片,客户端 V 依次可分割如下:
M - HTML DOM树
V - 视觉演示
C - 事件侦听器功能(终端用户交互和Ajax)
所以它基本上是一个M(M(M(MVC)C)C)C;)
请注意,一些起动器,甚至一些非常基本的&mdash ;教程在管理bean中混合/复制/平铺实体的属性,这将有效地使控制器成为模型。不用说,这是糟糕的设计(即不是一个干净的MVC设计)。
以下答案中的代码片段说明了正确的MVC方法:
- JSF控制器,服务和DAO
- 为实体创建主详细页面,如何链接它们以及要选择的bean范围
- Passing一个JSF2将pojo bean管理到EJB中或将所需的内容放入转移对象中
- 过滤器不初始化EntityManager
- 小面孔应用程序中的javax.persistence.TransactionRequiredException
In JSF MVC framework who is Model, View, and Controller?
This depends on the point of view (pun intented).
In the big architectural picture, your own JSF code is the V:
M - Business domain/Service layer (e.g. EJB/JPA/DAO)
V - Your JSF code
C - FacesServlet
In the developer picture, the architectural V is in turn dividable as below:
M - Entity
V - Facelets/JSP page
C - Managed bean
In the smaller client picture, the developer V is in turn dividable as below:
M - JSF component tree
V - Rendered HTML output
C - Client (webbrowser)
In the yet smaller JavaScript picture, the client V is in turn dividable as below:
M - HTML DOM tree
V - Visual presentation
C - Event listener functions (enduser interaction and Ajax)
So it's basically a M(M(M(MVC)C)C)C ;)
Note that some starters and even some —very basic— tutorials mingle/copy/flatten the entity's properties in the managed bean, which would effectively make the controller a model. Needless to say that this is poor design (i.e. not a clean MVC design).
The code snippets in the following answers illustrate the right MVC approach:
- JSF Controller, Service and DAO
- Creating master-detail pages for entities, how to link them and which bean scope to choose
- Passing a JSF2 managed pojo bean into EJB or putting what is required into a transfer object
- Filter do not initialize EntityManager
- javax.persistence.TransactionRequiredException in small facelet application
这篇关于JSF MVC框架中的MVC有哪些组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!