J2EE JavaServer Faces (JSF) Introduction Internetteknologi 2 (ITNET2)

Slides:



Advertisements
Similar presentations
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
Advertisements

Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
Chapter 1 The Study of Body Function Image PowerPoint
Java OSS Web Technologies By Dave Ford Introduction Purpose Describe Javas relationship to the OSS community Describe OSS tools used on recent project.
19 Copyright © 2005, Oracle. All rights reserved. Distributing Modular Applications: Developing Web Services.
21 Copyright © 2005, Oracle. All rights reserved. Oracle Application Server 10g Transaction Support.
1 Copyright © 2005, Oracle. All rights reserved. Introduction.
18 Copyright © 2005, Oracle. All rights reserved. Distributing Modular Applications: Introduction to Web Services.
4 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: Servlets.
11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
15 Copyright © 2005, Oracle. All rights reserved. Container-Managed Relationships (CMRs)
1 Copyright © 2005, Oracle. All rights reserved. Introducing the Java and Oracle Platforms.
9 Copyright © 2005, Oracle. All rights reserved. Modularizing JavaServer Pages Development with Tags.
8 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: JavaServer Pages.
J2EE Overview.
15 Copyright © 2005, Oracle. All rights reserved. Adding User Interface Components and Event Handling.
6 Copyright © 2005, Oracle. All rights reserved. Building Applications with Oracle JDeveloper 10g.
17 Copyright © 2005, Oracle. All rights reserved. Deploying Applications by Using Java Web Start.
XP New Perspectives on Microsoft Office Word 2003 Tutorial 7 1 Microsoft Office Word 2003 Tutorial 7 – Collaborating With Others and Creating Web Pages.
Microsoft Access 2007 Advanced Level. © Cheltenham Courseware Pty. Ltd. Slide No 2 Forms Customisation.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Enterprise Java and Data Services Designing for Broadly Available Grid Data Access Services.
View-Based Application Development Lecture 1 1. Flows of Lecture 1 Before Lab Introduction to the Game to be developed in this workshop Comparison between.
© Paradigm Publishing, Inc Access 2010 Level 1 Unit 1Creating Tables and Queries Chapter 2Creating Relationships between Tables.
Microsoft Access.
EIS Bridge Tool and Staging Tables September 1, 2009 Instructor: Way Poteat Slide: 1.
Natural Business Services for Construct Users Mark Barnard R&D Manager – Natural Business Services.
VOORBLAD.
Benchmark Series Microsoft Excel 2013 Level 2
© 2012 National Heart Foundation of Australia. Slide 2.
25 seconds left…...
Presentation 7 part 2: SOAP & WSDL.
PSSA Preparation.
© Paradigm Publishing, Inc Access 2010 Level 2 Unit 2Advanced Reports, Access Tools, and Customizing Access Chapter 8Integrating Access Data.
Presentation 10 SOAP on the Microsoft Platform (.NET)
From Model-based to Model-driven Design of User Interfaces.
Web Development with Karsten Schulz Terp-Nielsen Master Principal Sales Consultant Oracle Denmark.
Apache Struts Technology
Internetteknologi (ITNET1) Extra Presentation Java IDE Tool Support.
Spring, Hibernate and Web Services 13 th September 2014.
Integrating SOA and the Application Development Framework Shaun O’Brien Principal Product Manager – Oracle JDeveloper / ADF.
Internet Technologies 1 Master of Information System Management Java Server Faces Model/View/Controller Design Pattern for Web Development Slides.
Java Server Faces Model/View/Controller Design Pattern for Web Development Slides adapted from “Core JavaServer Faces” by Geary and Horstmann and the J2EE.
Structure of a web application1 Dr Jim Briggs. MVC Structure of a web application2.
UNIT-V The MVC architecture and Struts Framework.
JavaServer Faces: The Fundamentals Compiled from Sun TechDays workshops (JSF Basics, Web-Tier Codecamp: JavaServer Faces, Java Studio Creator; IBM RAD)
Java Server Faces Çağatay Çivici Apache MyFaces Team Member
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Grant Ronald Principal Product Manager JDeveloper and ADF for Forms Developers: Taking it to the next level.
JDeveloper 10g and JavaServer Faces: High-Performance UIs on the Web Avrom Roy-Faderman Senior Programmer May, 2006.
JSF road map (NI) Clientside validation Show problems
CSCI 6962: Server-side Design and Programming Introduction to Java Server Faces.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
Fall CIS 764 Database Systems Design L8. Web ….
Introduction to Web Dimitar Nenchev Ivan Nakov
Java Web Development with NetBeans IDE -- Kai Qian Chapter 5 JavaServer Faces (JSF) Technology.
JSF Framework Java Server Faces Presented by Songkran Totiya (6/10/2014)
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 41 JavaServer Face.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
1 Copyright © 2004, Oracle. All rights reserved. Oracle Application Development Framework.
2 Copyright © 2004, Oracle. All rights reserved. ADF Development Process.
SDJ INFOSOFT PVT. LTD. 2 BROWSERBROWSER JSP JavaBean DB Req Res Application Layer Enterprise server/Data Sources.
Apache Struts Technology A MVC Framework for Java Web Applications.
Intro to JavaServer Faces Mimi Opkins CECS 493 Fall 2016.
Structure of a web application
Unit 6-Chapter 2 Struts.
JavaServer Faces: The Fundamentals
Presentation transcript:

J2EE JavaServer Faces (JSF) Introduction Internetteknologi 2 (ITNET2)

Ingeniørhøjskolen i Århus Slide 2 Agenda JavaServer Faces (JSF): –Motivation for JSF –Visual Tool Support –JSF Legacy & Elements –Events –Managed Beans –Tool support

Ingeniørhøjskolen i Århus Slide 3 Motivation ASP.NET 2 + VS 2003/2005 –New approach to Web development –JSP/Servlet specification could not compete –JSF introduced to supplement JSP/Servlet JSF is a Sun Java specification –Implementations from Sun, IBM, Oracle, Exadel A UI framework for Java Web applications –Easy component-based UI development –Swing like event model –“Code behind” like approach –Designed for visual tool support

Ingeniørhøjskolen i Århus Slide 4 Visual Tool Support from IBM WSAD, Netbeans 5.5, JDeveloper 11g

Ingeniørhøjskolen i Århus Slide 5 JSF Legacy JSF uses JSP, EL, JSTL, Servlet technologies It does NOT replace JSP/Servlet technology Introduces backing beans and event programming NOT a must JSF works with JDBC, JPA, POJO, EJB, WS JSF supports FrontController pattern out of the box STRUTS heritage Good news – all we know may still be applied

Ingeniørhøjskolen i Århus Slide 6 Elements of JSF FacesServlet (central processing unit) Web.xml (well-known from JSP/Servlet J2EE) Faces-config.xml (configures navigation and managed beans etc.) JSF-pages / JSF-tags (view implementations) Managed Beans (beans controlled by framework) Backing beans (event handler code) Navigation Rules (front controller pattern) Validators (same as.NET) Converters (same as.NET)

Ingeniørhøjskolen i Århus Slide 7 Faces Servlet Required FrontController Implemented by the framework – not developers All JSF request must pass through this Configured via web.xml Reads faces-config.xml for navigation and managed beans Faces Servlet javax.faces.webapp.FacesServlet 1 Page navigation is NOT required to use frontController

Ingeniørhøjskolen i Århus Slide 8 Faces-config.xml Configures navigation, managed beans etc. May be split up into several implementations –Managed-beans.xml –Navigation.xml –And other files Depending on the tool

Ingeniørhøjskolen i Århus Slide 9 Managed-beans.xml <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" " SessionBean1 visualebtest.SessionBean1 session Page1 visualebtest.Page1 request ApplicationBean1 visualebtest.ApplicationBean1 application RequestBean1 visualebtest.RequestBean1 request Backing bean Of “Page1.JSF” Managaed Beans are accessible in all JSF pages via EL: ${Page1.submit}

Ingeniørhøjskolen i Århus Slide 10 <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN" " /Page1.jsp case1 /Page2.jsp Navigation.xml FrontController pattern implemented by defining a number of cases (actions) which e.g. a button press Might react to – and where to navigate to Counters anti-pattern: spaghetti

Ingeniørhøjskolen i Århus Slide 11 JSF Pages / Taglibs Open to many different technologies In practice: JSP integration JSF Views are JSP pages using JSF tags XML Style Like ASP.NET 2, UI components are represented as different elements e.g. Like ASP.NET – you may make your own components

Ingeniørhøjskolen i Århus Slide 12 JSF taglibs Table component A JSP page with JSF components Created with Visual Designer Navigation link Binding to backing bean

Ingeniørhøjskolen i Århus Slide 13 Backing Beans Abstracting event handling and data model away from JSF pages Somewhat like ”code behind” in ASP.NET Event Oriented Actions ActionListeners

Ingeniørhøjskolen i Århus Slide 14 Event Handling Actions: may change page using ”return” –return: null for post back –return: case1 – frontcontroller -> Page2.jsf –Checks faces-config.xml or navigation.xml ActionListeners occur before Actions and no page change JSF binding to action Java Backing Bean Action Event Handler (ASP.NET = Click)

Ingeniørhøjskolen i Århus Slide 15 Managed Beans Managed Beans are JavaBeans JavaBeans must be reflectable –(getter,setter, no-arg constructor) A Managed Bean is a Value Object pattern Holding scoped state for the Web application Application, Session, Request, Page1, User Like in JSP Backing Beans are Managed Beans May be accessed from anywhere in Web application –JSF using EL: Page1.button1 –Java: Page1 page = (Page1) this.getPage1(); –page.button1.setToolTip("Press for fun");

Ingeniørhøjskolen i Århus Slide 16 Databinding A frequent task is RDBMS access JSF has widespread support for this May be done –Manual: JDBC coding (see JSP slides for example) –RowSet (com.sun.sql.rowset.CachedRowSetXImpl) –Entity Beans (JPA, TopLink, Hibernate, EJB 2.1/3.0) Next we examplify the latter two with Netbeans 5.5 tool support Drag-n-drop and Wizard

Ingeniørhøjskolen i Århus Slide 17 RowSet (”the qucik-n-dirty approach”) Most J2EE IDE tools have a Runtime tab with database acces Select database table and drag to designer Creates a member in ”Session” managed bean

Ingeniørhøjskolen i Århus Slide 18 Binding Table to Rowset

Ingeniørhøjskolen i Århus Slide 19 JSF Resulting Tags A ui:Table element is added with colums EL is used to bind the data sources

Ingeniørhøjskolen i Århus Slide 20 Binding to City Drop-Down with City Table

Ingeniørhøjskolen i Århus Slide 21 Alternative: Entity Classes RowSet approach OK for small solutions Not good in case of business logic code Instead: use Entity classes –A) Wizard: Generate Entity Classes –B) Wizard: Generate JSF pages from Entity A) provides a domain layer (model layer) B) will provide a control / view layer

Ingeniørhøjskolen i Århus Slide 22 Entity Classes from Database You may use this layer for Other technologies as well – Including Web services, CORBA, Java RMI, Swing, etc.

Ingeniørhøjskolen i Århus Slide 23 Model Generated Access using JPA – write own DAO layer

Ingeniørhøjskolen i Århus Slide 24 JSF Pages from Entities Will created View and Control / BL layers as well Entity Manager Controls the DB Access including transactions

Ingeniørhøjskolen i Århus Slide 25 Persistence.xml Gets generated by tool – but can write yourself

Ingeniørhøjskolen i Århus Slide 26 JSF Pages Generated

Ingeniørhøjskolen i Århus Slide 27 Result For now – JSF pages wizard does NOT work With Visual Designer applications …

Ingeniørhøjskolen i Århus Slide 28 Architectural Considerations from JSF FrontController is directly supported – use it Event based programming -> look out for layer separation (do not write business logic layer code in the event handlers of the backing bean) Like ASP.NET – Database drag-n-drop is supported with table / component data binding Watch out for this approach, use only for small systems with little or no business code Alternative: generate Entity classes (EJB, JPA) and event JSF code

Ingeniørhøjskolen i Århus Slide 29 Stefan’s Considerations on JSF JSF is a strong alternative to ASP.NET – but much to learn RowSet approach (quick-n-dirty) almost as easy as Visual Studio Entity (EE) approach much better than ASP.NET FrontController pattern / navigation.xml is a very strong feature – compared to master-details JSF wins over ASP.NET for very large projects ASP.NET / VS 2005 more productive for RAD development of small to medium sized projects NetBeans requires tons of RAM – but runs extremely well on 2 GB Dual Core machine ;-) Nice to be rich … But its FREE and runs on Solaris / Linux / Windows Trying to develop JSF without tool support is doomed to fail!

Ingeniørhøjskolen i Århus Slide 30 Advice for Assignment 1 Consider NOT using JSF (as stated earlier) Use JSP/Servlets – as you will learn much about server programming from this Try implementing a few pages also in JSF But beware of NetBeans not working properly on IHA Lab machines …