intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Bài giảng Phát triển ứng dụng nguồn mở: Bài 6 - Đoàn Thiện Ngân

Chia sẻ: 5A4F5AFSDG 5A4F5AFSDG | Ngày: | Loại File: PDF | Số trang:22

60
lượt xem
4
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Bài 6 - Java web application JSF – Java EE. Nội dung chính trong bài giảng này gồm có: JSF ─ Java Server Face, Entity Classes from Database Wizard, JSF Pages from Entity Classes Wizard, JSF Web application CRUD with MySQL Database. Mời các bạn tham khảo.

Chủ đề:
Lưu

Nội dung Text: Bài giảng Phát triển ứng dụng nguồn mở: Bài 6 - Đoàn Thiện Ngân

  1. Bài 6: Java Web Application JSF – Java EE GV: ĐOÀN THIỆN NGÂN Đoàn Thiện Ngân Bài 6 - 1/22
  2. Nội dung • JSF ─ Java Server Face • Entity Classes from Database Wizard • JSF Pages from Entity Classes Wizard • JSF Web application CRUD with MySQL Database Đoàn Thiện Ngân Bài 6 - 2/22
  3. Tài liệu tham khảo 1. Java™ For Programmers, 2nd Edition, Deitel® Developer Series, Chapters 26 & 27 2. NetBeans IDE 7 Cookbook, 2011, Packt Publishing 3. Oracle Java EE 7 Tutorial http://docs.oracle.com/javaee/7/tutorial/doc /jsf-intro.htm 4. Netbeans Tutorial, https://netbeans.org/kb/docs/web/jsf20- intro.html Đoàn Thiện Ngân Bài 6 - 3/22
  4. JSF Web Application • JSP was great in its time. But as with everything, time passed and other technologies were developed that made it even easier to generate this same kind of content, and on top of that, overcame many of the limitations that were introduced with JSP. • Enter JSF. It brings a graphical development mentality, similar to Swing's, which relies on a set of reusable UI components and event-driven approach. • Instead of totally breaking away from its roots, JSF 2.0 can also be developed in the same way JSP is; in fact, a JSF application is a JSP/servlets application. • Typically, Web Applications are developed using the MVC design pattern. This pattern works great with JSF since, in a typical JSF application, the View is the page we write, the Model is the data we wish to show, and the Controller is the FacesServlet. Every request passes through the FacesServlet. The configuration file for the FacesServlet is faces-config.xml. Đoàn Thiện Ngân Bài 6 - 4/22
  5. What is Java EE? • Java EE (Enterprise Edition) is a widely used platform containing a set of coordinated technologies that significantly reduce the cost and complexity of developing, deploying, and managing multitier, server-centric applications. • Java EE builds upon the Java SE platform and provides a set of APIs (application programming interfaces) for developing and running portable, robust, scalable, reliable and secure server-side applications. Đoàn Thiện Ngân Bài 6 - 5/22
  6. What is Java EE? Fundamental components of Java EE include: • Enterprise JavaBeans (EJB): a managed, server-side component architecture used to encapsulate the business logic of an application. EJB technology enables rapid and simplified development of distributed, transactional, secure and portable applications based on Java technology. • Java Persistence API (JPA): a framework that allows developers to manage data using object-relational mapping (ORM) in applications built on Đoàn theThiện Java Platform. Ngân Bài 6 - 6/22
  7. JavaScript and Ajax Development • JavaScript is an object-oriented scripting language primarily used in client-side interfaces for web applications. • Ajax (Asynchronous JavaScript and XML) is a Web 2.0 technique that allows changes to occur in a web page without the need to perform a page refresh. • JavaScript toolkits can be leveraged to implement Ajax-enabled components and functionality in web pages. Đoàn Thiện Ngân Bài 6 - 7/22
  8. JavaServer Faces 2.1 CRUD Application from a Database http://netbeans.org/kb/docs/web/jsf20-crud.html • View and modify data contained in the database - otherwise referred to as CRUD (Create, Read, Update, Delete) functionality. It relies on: – JavaServer Faces (JSF) 2.0 for front-end web pages, validation handling, and management of the request-response cycle. – Java Persistence API (JPA) 2.0 generates entity classes from the database, and manage transactions. – Enterprise JavaBeans (EJB) 3.1, stateless EJBs that access the entity classes, and contain the business logic for the application. Đoàn Thiện Ngân Bài 6 - 8/22
  9. JavaServer Faces 2.1 CRUD Application from a Database • NetBeans IDE provides two wizards which generate all of the code for the application. – The first is the Entity Classes from Database wizard which enables you to generate entity classes from the provided database. – After creating entity classes, you use the JSF Pages from Entity Classes wizard to create JSF managed beans and EJBs for the entity classes, as well as a set of Facelets pages to handle the views for entity class data. Đoàn Thiện Ngân Bài 6 - 9/22
  10. JavaServer Faces 2.1 CRUD Application from a Database • MySQL Database consult • http://kenai.com/projects/consultingagencys ol/downloads/download/base/mysql- consult.zip • NetBeans 7 • Glassfish Server 3 • MySQL JDBC Đoàn Thiện Ngân Bài 6 - 10/22
  11. JavaServer Faces 2.1 CRUD Application from a Database • New Project: Java Web/ Web Application • Server: Glassfish Server • Java EE 6 Web • Framework: JavaServer Faces • Library: JSF 2.1 Đoàn Thiện Ngân Bài 6 - 11/22
  12. JavaServer Faces 2.1 CRUD Application from a Database • R-Click Project/ New/ Entity Classes from Database … Đoàn Thiện Ngân Bài 6 - 12/22
  13. JavaServer Faces 2.1 CRUD Application from a Database • Data Source: jdbc/consult • Data Tables: Add All Đoàn Thiện Ngân Bài 6 - 13/22
  14. JavaServer Faces 2.1 CRUD Application from a Database Đoàn Thiện Ngân Bài 6 - 14/22
  15. JavaServer Faces 2.1 CRUD Application from a Database Đoàn Thiện Ngân Bài 6 - 15/22
  16. JavaServer Faces 2.1 CRUD Application from a Database • Source Packages • jsf.entities – Address.java – Billable –… Đoàn Thiện Ngân Bài 6 - 16/22
  17. JavaServer Faces 2.1 CRUD Application from a Database • R-Click Project; New/ JSF Pages from Entity Classes … Đoàn Thiện Ngân Bài 6 - 17/22
  18. JavaServer Faces 2.1 CRUD Application from a Database Đoàn Thiện Ngân Bài 6 - 18/22
  19. JavaServer Faces 2.1 CRUD Application from a Database Đoàn Thiện Ngân Bài 6 - 19/22
  20. JavaServer Faces 2.1 CRUD Application from a Database • Tương tác với mỗi Entity có 4 trang: – Create.xhtml – Edit.xhtml – List.xhtml – View.xhtml • Chú ý các trang trong jsf, jsf.sessions Đoàn Thiện Ngân Bài 6 - 20/22
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2