JSF MVC框架中的MVC有哪些组件? [英] What components are MVC in JSF MVC framework?

查看:123
本文介绍了JSF MVC框架中的MVC有哪些组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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方法:




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 MVC框架中的MVC有哪些组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆