Java 使用 JSF、PrimeFaces 和 JPA:在不使用生成的 CRUD 类、表单等的情况下创建基本的 WebApp
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18789062/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using JSF, PrimeFaces and JPA: Create Basic WebApp without using Generated CRUD Classes, Forms, etc
提问by user2774489
I am trying to build a basic CRUD application with NetBeans 7.4, JSF, PrimeFaces and JPA using MySQL.
我正在尝试使用 MySQL 使用 NetBeans 7.4、JSF、PrimeFaces 和 JPA 构建一个基本的 CRUD 应用程序。
I have successfully done this by using the NetBeans wizards. I want to do this from scratch, no wizards.
我已经通过使用 NetBeans 向导成功地做到了这一点。我想从头开始,没有向导。
There seems to be a lack of support for the combo of JSF, PrimeFaces and JPA. When I say "lack", I mean a full example (I might be asking too much), without using the CRUD auto-gen templates/classes AND shows actual queries coded and passed to the datatables(primefaces). YouTube is full of non-English speaking examples using Hibernate (not JPA) and other examples that show flashy GUI's with no code.
似乎缺乏对 JSF、PrimeFaces 和 JPA 组合的支持。当我说“缺乏”时,我的意思是一个完整的例子(我可能要求太多),不使用 CRUD 自动生成模板/类,并显示编码并传递给数据表(素面)的实际查询。YouTube 上充满了使用 Hibernate(不是 JPA)的非英语示例以及其他无需代码即可显示华丽 GUI 的示例。
So far I understand you need an @Entity class (provides the physical build of the tables), a Controller (serializable) and the .xhtml web page to show the datatable.. what else? Also, I'm not seeing any posts or examples where queries are using with JPA/JSF and how they are tied together (in one place). I need to connect the dots here so that I can leverage JSF/JPA to create simple queries to populate my PF DataTables. I've read the blogs and I've googled the intranets until I'm blue in the face. Sending me a list of URL's to read to learn about each product is something I've already done. I get what they do independently, but am looking for the "How do they all connect" answer with maybe some basic code examples!! :)
到目前为止,我了解到您需要一个 @Entity 类(提供表的物理构建)、一个控制器(可序列化)和 .xhtml 网页来显示数据表......还有什么?此外,我没有看到任何帖子或示例,其中查询与 JPA/JSF 一起使用以及它们如何绑定在一起(在一个地方)。我需要在这里连接点,以便我可以利用 JSF/JPA 创建简单的查询来填充我的 PF 数据表。我已经阅读了博客并在内部网中搜索了谷歌,直到我脸色发青。向我发送要阅读的 URL 列表以了解每个产品是我已经完成的事情。我得到了他们独立做的事情,但我正在寻找“他们如何全部连接”的答案以及一些基本的代码示例!!:)
回答by Noah Martin
I think this should help you: http://www.tutorialspoint.com/jsf/jsf_tutorial.pdf
我认为这应该对您有所帮助:http: //www.tutorialspoint.com/jsf/jsf_tutorial.pdf
Tung
董
回答by hanan Ahmed
look.If you need an example about CRUD operation using JPA/EJB as Model layer and JSF as view layer,you can see the follwing example:
看。如果你需要一个关于使用JPA/EJB作为模型层和JSF作为视图层的CRUD操作的例子,你可以看下面的例子:
also my own blog is based on many examples explaining this.These examples are using JPA2/EJB3 as model and JSF2 and primfaces as view you can see
我自己的博客也是基于许多解释这一点的例子。这些例子使用 JPA2/EJB3 作为模型,使用 JSF2 和 primfaces 作为视图,你可以看到
http://jsfspotlight.blogspot.com/2013/05/jsf2ejb3-preparing-your-environment.html(this post for explaining how to prepare your environment before developing EJB/JSF Applications
http://jsfspotlight.blogspot.com/2013/05/jsf2ejb3-preparing-your-environment.html(这篇文章解释了在开发 EJB/JSF 应用程序之前如何准备环境
http://jsfspotlight.blogspot.com/2013/05/ejbjsf-master-detail-web-application-in_25.html(in this post i explain in details how to create EJB/JSF master_detail Application including what you need about connecting model and view layers)
http://jsfspotlight.blogspot.com/2013/05/ejbjsf-master-detail-web-application-in_25.html(在这篇文章中我详细解释了如何创建 EJB/JSF master_detail 应用程序,包括您需要的连接模型并查看图层)
explore the blog for more examples
浏览博客以获取更多示例
回答by Koks Skirtumas
Try this archetype which will create you an example and then check how it is implemented: https://github.com/ignl/happyfacescrud. You will learn about Spring, Spring security, Spring WS, JPA and Hibernate, Spring data and QueryDsl for easier querying, and custom JSF components which will make you very productive jsf developer.
试试这个原型,它将为您创建一个示例,然后检查它是如何实现的:https: //github.com/ignl/happyfacescrud。您将了解 Spring、Spring 安全性、Spring WS、JPA 和 Hibernate、Spring 数据和 QueryDsl 以便于查询,以及自定义 JSF 组件,这将使您成为非常高效的 jsf 开发人员。