除了 JSF/JSP for Java EE 之外,还有其他强集成的表示层工具吗?

发布于 2024-07-08 08:27:02 字数 279 浏览 6 评论 0原文

我在大学教授 Java EE,这是一个学生问的问题。 我说“不”,但我不太确定,所以我想我可以问问你们强大的开发人员。 :)

基本上,我想做的是使用在我的上下文中的实体:cat getter、setter 等,就像普通的 POJO 一样。 如果我使用 EJB 来使用其远程接口,实体就会与核心基础设施解耦,所以这是不行的。

我想过在我的硕士论文中写一个这样的层。 如果这是一个死主意,请随时告诉我。 如果没有,请告诉我您是否想要一个。

或者如果有这样的工具,请告诉我!

I'm teaching Java EE at the university, and this was a question a student asked. I said "no", but I wasn't really sure, so I thought I might ask you mighty developers. :)

Basically, what I'd like to do is to use entities if they were in my context: cat getters, setters, etc, so like normal POJOs. if I use an EJB using its remote inferface, the entities gets decoupled from the core infrastructure, so that's a no-go.

I thought about writing a layer such as this in my MSc thesis. If it's a dead idea, feel free to tell me. If it's not, tell me if you'd like one.

Or if there is such a tool out there, let me know!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

睫毛上残留的泪 2024-07-15 08:27:02

在一个基本的现代世界 Java EE 应用程序中,它被分成各个层,其中有 4 个基本层

+--------------------+
|   Presentation     |
+--------------------+
| Controller/Actions |
+--------------------+
| Business Delegate  |
|     (Service)      |
+--------------------+
|  Data Access Layer |
+--------------------+
|      Database      |
+--------------------+

您的应用程序应该从一开始就分成这些层,这样您就可以在任何给定的时间点替换任何层而不影响它的任何同级层。

例如,如果您将 JDBC 用于数据访问层,您应该能够将其替换为 Hibernate,而不会影响业务委托或数据库层。 使用这种架构的好处是允许与多种技术协作。 您的业​​务代表(服务层)应该能够与 Web 服务对话并处理应用程序,甚至无需使用浏览器!

关于使用 JSP 作为表示层,还有其他可用的技术,例如 velocityfreemarker,正如上面iberck提到的,tapestry也有自己的渲染引擎。 您还可以使用 XML + XSLT 来呈现 UI。 还有一些 UI 管理应用程序可供使用,例如 Tilessitemesh,帮助您将各种技术集成为页面的不同组件并将它们显示为一个整体。

您还可以使用与 JNLP< /a> 并开发桌面风格的企业应用程序。 我们所需要的只是一点想象力和客户需求,我们可以使用任何东西作为表示层。

In a basic modern world Java EE application, it is broken into various layers, where you have 4 basic layers

+--------------------+
|   Presentation     |
+--------------------+
| Controller/Actions |
+--------------------+
| Business Delegate  |
|     (Service)      |
+--------------------+
|  Data Access Layer |
+--------------------+
|      Database      |
+--------------------+

Your applications should be split into these layer right from the beginning, such that you can at any given point of time replace any layer without effecting any of it's sibling layer.

Example if you used JDBC for the Data Access layer, you should be able to replace it with Hibernate without affecting the business delegate or Database layer. The benefit of using such an architecture is to allow collaboration with multiple technologies. You business delegate (service layer) should be able to talk to a web service and handle the application processing without even going to a browser!

Regarding using JSP as the presentation layer, there are other technologies available like, velocity, freemarker, as iberck mentioned above, tapestry also has it's own rendering engine. You can use XML + XSLT also to render the UI. There are UI managing apps also available like Tiles and sitemesh, that help you integrate various techs as different components of the page and show them as one.

You can also use light weight swing components clubbed with JNLP and develop a desktop style enterprise application. All we need is a little imagination and client requirement and we can use literally anything as the presentation layer.

似狗非友 2024-07-15 08:27:02

我从未尝试过,但 JSF 应该比 JSP 与 Facelets 配合得更好。

IBM 有一篇关于它的文章

I've never tried it, but JSF is supposed to work better with Facelets than with JSP.

IBM has an article about it.

淡淡的优雅 2024-07-15 08:27:02

啊。 看来你没有正确理解我的问题:)

Bean 是用来在应用程序内提供服务的。 假设我想开发一个带有 swing gui 的独立 java 应用程序,并且从该应用程序中我想使用 java ee 应用程序范围内存在的实体。

这就是我想要无缝地:以直观的方式创建实体、修改它们、删除它们,而不关心 EntityManager 分离问题(如果您远程调用 EJB 并且它传回实体对象,它将被分离)返回之前)。

我不想开发网络应用程序。 JSF/JSP 等是高度集成的,但在许多环境中,独立的客户端应用程序会更好。 :)

Ah. It seems you didnt get my question right :)

Beans are there to provide services inside an application. Lets say I'd like to develop a standalone java application with a swing gui, and from that application I'd like to use the entities present at the java ee app's scope.

That is what I'd like to to seamlessly: create entities, modify them, delete them in an intuitive way, without caring about EntityManager-detachment problems (if you call an EJB remotely and it passes back an entity object, it will be detached before return).

I dont want to develop a web application. JSF/JSP and such is strongly integrated, but in many environments a standalone client application would be better. :)

扛起拖把扫天下 2024-07-15 08:27:02

看到你在中间的评论,我发现你想要一个基于 Java EE 的桌面框架。

这里的答案是 JSF 通过 servlet api 工作。 绝对是针对网络的,但是等等,您仍然可以在您的应用程序中嵌入 tomcat 或 jetty!

可能性几乎是无限的,如果您的业务层定义良好,只需构建一个调用您的业务功能的摆动层即可。

另外,Java EE 是一个 API,某些部分可以替换,也可以只使用其中的一部分。 该容器主要用于处理 EJB、Servlet JNDI 和其他小东西。 所有这些也可以由桌面应用程序使用。

因此,答案取决于您的具体目标和应用程序的实际设计/实现。

Seeing your comment in the middle, i see that you want a desktop framework over Java EE.

The answer here is that JSF works over the servlet api. And is definitely for the web, but wait, you can still embed tomcat or jetty in your application!

The possibilities are pretty much endless, if your business layer is well defined, just build a swing layer that calls your business functions.

Also, Java EE is an API, some parts can be replaced, or you can just use part of it. The container is mostly for dealing with EJB, Servlets JNDI and other small stuff. All this can be used by desktop apps also.

So the answer depends on your specific goal and the actual design/implementation of the application.

十二 2024-07-15 08:27:02

一种替代方案是Spring 框架。 Spring 提供了自己的支持,将实体对象绑定到视图,并在连接后为您处理获取/设置。 有许多 Spring 模块可供选择。 Spring MVC 和 Spring Webflow 都值得一试。 Spring MVC (IMO) 更容易上手,但 Sring Webflow 允许更复杂的导航和更多范围选项(例如:流范围)。 如果您正在寻找一本书,Spring In Action 就是血统。 为了使用 Spring,您需要解决一些概念(例如依赖注入),但这是值得花时间的。

One alternative is the Spring Framework. Spring provides its own support for binding entity objects to the view and handles the getting/setting for you once it is wired up. There are many Spring modules to pick and choose from. Spring MVC and Spring Webflow are both worth checking out. Spring MVC (IMO) is simpler to get started with, but Sring Webflow allows for more complex navigation and more scope options (ex: flow scope). If you're looking for a book Spring In Action is descent. There are some concepts you will need to tackle (such as dependency injection) in order to use Spring but it is well worth the time.

歌入人心 2024-07-15 08:27:02

另一种选择是 Tapestry5 框架。
Tapestry 是一个开源框架,用于用 Java 创建动态、健壮、高度可扩展的 Web 应用程序。 Tapestry 是对标准 Java Servlet API 的补充和构建,因此它可以在任何 servlet 容器或应用程序服务器中工作。

Tapestry 将 Web 应用程序划分为一组页面,每个页面均由组件构建。 这提供了一致的结构,允许 Tapestry 框架承担关键问题的责任,例如 URL 构建和分派、客户端或服务器上的持久状态存储、用户输入验证、本地化/国际化以及异常报告。 开发 Tapestry 应用程序涉及使用纯 HTML 创建 HTML 模板,并将模板与少量 Java 代码组合起来。 在 Tapestry 中,您可以根据对象以及这些对象的方法和属性来创建应用程序,特别是不根据 URL 和查询参数来创建应用程序。 Tapestry 为 Java Web 应用程序带来了真正的面向对象开发。

Another alternative is Tapestry5 framework.
Tapestry is an open-source framework for creating dynamic, robust, highly scalable web applications in Java. Tapestry complements and builds upon the standard Java Servlet API, and so it works in any servlet container or application server.

Tapestry divides a web application into a set of pages, each constructed from components. This provides a consistent structure, allowing the Tapestry framework to assume responsibility for key concerns such as URL construction and dispatch, persistent state storage on the client or on the server, user input validation, localization/internationalization, and exception reporting. Developing Tapestry applications involves creating HTML templates using plain HTML, and combining the templates with small amounts of Java code. In Tapestry, you create your application in terms of objects, and the methods and properties of those objects -- and specifically not in terms of URLs and query parameters. Tapestry brings true object oriented development to Java web applications.

愚人国度 2024-07-15 08:27:02

如今,我所知道的任何合适的 Java 框架中都存在 bean 背后的思想。 正如rich提到的,Spring是一个很好/很棒的全能业务逻辑框架(查看它的jdbc 模板 类,这些简直太棒了 - 另一个很棒的宝石是 applicationContext.xml 这是),对于视图层我个人更喜欢 Apache Wicket.

我不认为您应该创建自己的框架,而是找到一个适合您需求的框架并开始为其代码库做出贡献,这样您就可以从已经形成的用户群开始,并且您的代码将得到更彻底的编写,从而反过来会让你成为一个更好的程序员。

The ideology behind beans is nowadays in any proper Java framework I know of. As rich mentioned, Spring is a good/great all-around business logic framework (check out its jdbc template classes, those are simply awesome - another great gem is applicationContext.xml which is ) and for view layer I personally prefer Apache Wicket.

I don't believe you should make your own but instead find a framework that suits your needs and start contributing to its code base, that way you get to start with an already formed user base and your code will get authored more thoroughly which in turn will make you a better programmer.

相思故 2024-07-15 08:27:02

grails (http://www.grails.org/) 或 griffon (http://griffon.codehaus.org/) 可能感兴趣

grails (http://www.grails.org/) or griffon (http://griffon.codehaus.org/) may be of interest

断肠人 2024-07-15 08:27:02

StringTemplate 是由 ANTLR 背后的人 Terrence Parr 编写的。 如果您有兴趣从模型生成某种文本表示,那么这非常好。

我使用它从同一模型生成 XML、网页和 点文件 取得了出色的结果。 您编写一个模板来呈现对象。 该模板可以根据从模型派生的数据调用其他模板(包括递归地)。 (qv 图片函数 )

Getter 和 map.get() 可直接从模板内调用。 该模型可以是任何 POJO。 ST 以其与控制器的严格分离而自豪,因此模板本身只允许很少的逻辑。

与所有这些小语言一样,它是新的东西需要学习,并且可能不是您正在寻找的东西。 这非常适合我。

StringTemplate is written by Terrence Parr, the guy behind ANTLR. If you're interested in generating some kind of textual presentation from a model, this is very good.

I have had excellent results using it to generate XML, web pages and dot files from the same model. You write a template to render an object. That template can call other templates (including recursively), based on the data derived from the model. (q.v. Picture Functions)

Getters and map.get() are callable directly from within the templates. The model can be any POJO. ST prides itself on its strict separation from the controller, so very little logic is allowed in the templates themselves.

As with all these little languages, it's something new to learn, and may not be what you're looking for. It was a really good fit for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文