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

本文是小编为大家收集整理的关于JSF MVC框架中哪些组件是MVC?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

在JSF MVC框架中谁是模型,视图和控制器?

推荐答案

这取决于观点(双关语意图).

在大型建筑图片中,您自己的JSF代码是 v :

m - 业务域/服务层(例如ejb/jpa/dao)
v - 您的JSF代码
c - Facesservlet

在开发人员图片中,架构 v 依次可分配如下:

m - 实体
v - facelets/jsp页
c - 托管豆

在较小的客户端图片中,开发人员 v 依次可分配如下:

m -JSF组件树
v - 渲染的HTML输出
c - 客户端(webbrowser)

在较小的JavaScript图片中,客户端 v 依次可分配如下:

m -html dom树
v - 视觉呈现
c - 事件侦听器函数(enduser互动和ajax)

因此,基本上是M(M(MVC)C)C;)

请注意,一些启动器,甚至有些(非常基本的教程)在托管bean中混合/复制/弄平了实体的属性,这可以有效地使控制器成为模型.不用说这是不良的设计(即不是干净的MVC设计).

以下答案中的代码片段说明了正确的MVC方法:

在书籍中 jsf in Java ee in Java ee的明确指南8 ,第8章" Backing Beans",第276页,雅加达雅加达面孔的权威指南10 ,第8章"背豆",第288页,下面的维恩图用于说明MVC Paradigm在上下文中相关的Backing Bean的位置致JSF开发人员.版权免责声明:上述书籍是由我撰写的,图片是由我创建的.

在此处输入图像说明

其他推荐答案

m Odel将是您的ManagedBean

v iew将为jsp,XHTML(好吧,您可以在此处容纳各种视图)

c ontroller将为FacesServlet

更新,希望这张图片有助于更多

在此处输入图像说明

其他推荐答案

面孔servlet管理着面孔生命周期,因此从某种意义上说,控制器与您自己的代码结合在一起,在每个生命周期阶段可能会被调用

lifecycle.gif

本文地址:https://www.itbaoku.cn/post/627448.html

问题描述

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:

In the books The Definitive Guide to JSF in Java EE 8, chapter 8 "Backing beans", page 276, and The Definitive Guide to Jakarta Faces in Jakarta EE 10, chapter 8 "Backing Beans", page 288, the below Venn diagram is used to illustrate the position of the backing bean in the MVC paradigm within the context relevant to the JSF developer. Copyright disclaimer: aforementioned books are written by me and the picture is created by me.

enter image description here

其他推荐答案

M odel would be your ManagedBean

V iew would be jsp,XHTML (well you can accommodate various views here )

C ontroller will be FacesServlet

Update, hope this picture helps more

enter image description here

其他推荐答案

The faces servlet manages the faces lifecycle so in that sense it is the controller combined with your own code that may get called during each lifecycle phase

http://www.java-samples.com/images/jsf-lifecycle.gif