JavaServer Faces framework. 2001 Craig McClanahan is presented that created Struts web framework and based on experience gathered designed JavaServer.

Slides:



Advertisements
Similar presentations
8 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: JavaServer Pages.
Advertisements

JSP and Servelets.
CGI programming. Common Gateway Interface interface between web server and other programs (cgi scripts) information passed as environment variables passed.
JSF Portlet Backing Beans and UI Components Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in.
Apache Struts Technology
JSP1 Java Server Pages (JSP) Introducing JavaServer Pages TM (JSP TM ) JSP scripting elements.
Web applications using JavaServer Faces (JSF) A brief introduction 1JavaServer Faces (JSF)
Struts1 Apache Struts Dr Jim Briggs. Struts2 What is Struts? Struts is an open source framework for building Java web applications Supports MVC/Model.
JBoss Seam: Contextual Components Jason Bechtel
Internet Technologies 1 Master of Information System Management Java Server Faces Model/View/Controller Design Pattern for Web Development Slides.
JavaServer Faces. Objectives To implement dynamic web pages with JavaServer Faces (JSF) technology To learn the syntactical elements of JavaServer Faces.
Layers & Tiers Umair Javed Lec - 41.
Java Server Faces Model/View/Controller Design Pattern for Web Development Slides adapted from “Core JavaServer Faces” by Geary and Horstmann and the J2EE.
ASP.NET Programming with C# and SQL Server First Edition
Create a New Application and Project Open the Create Application dialog. Enter the application name of your choice and the directory. Select No Template.
Introduction to JavaServer Faces Jeff Swisher Director of Consulting Services Dunn Solutions Group.
Introduction to Java web programming Dr Jim Briggs JWP intro1.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
Introducing JavaBeans Lesson 2A / Slide 1 of 30 JDBC and JavaBeans Pre-assessment Questions 1.Which of the given symbols is used as a placeholder for PreparedStatement.
Struts 2.0 an Overview ( )
JavaServer Faces: The Fundamentals Compiled from Sun TechDays workshops (JSF Basics, Web-Tier Codecamp: JavaServer Faces, Java Studio Creator; IBM RAD)
11. Java-Based Web: JSP, JSF. 2 Motto: Rule 1: Our client is always right Rule 2: If you think our client is wrong, see Rule 1. - Anonymous.
1 Chính phủ điện tử TS. Phạm Văn Tính Khoa CNTT, ĐH Nông Lâm TP.HCM
Pittsburgh Java User Group– Dec Java PureFaces: A JSF Framework Extension.
XForms: A case study Rajiv Shivane & Pavitar Singh.
CSCI 6962: Server-side Design and Programming Validation Tools in Java Server Faces.
JDeveloper 10g and JavaServer Faces: High-Performance UIs on the Web Avrom Roy-Faderman Senior Programmer May, 2006.
JavaServer Faces Jeff Schmitt October 5, Introduction to JSF Presents a standard framework for building presentation tiers for web applications.
1 Lecture 24 George Koutsogiannakis Spring 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
JSF road map (NI) Clientside validation Show problems
CSCI 6962: Server-side Design and Programming Introduction to Java Server Faces.
 Embeds Java code  In HTML tags  When used well  Simple way to generate dynamic web-pages  When misused (complex embedded Java)  Terribly messy.
Chapter 8 Script-free pages. Problem with scripting in JSP When you use scripting (declaration, scriplet, expressions) in your JSP, you actually put Java.
Web applications using JavaServer Faces (JSF) A brief introduction 1JavaServer Faces (JSF)
J2EE Structure & Definitions Catie Welsh CSE 432
ASP.NET.. ASP.NET Environment ASP.NET is Microsoft's programming framework that enables the development of Web applications and services. It is an easy.
JSF Introduction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
Case Study + MVC Lec Error Pages By means of the page directive, a JSP can be given the responsibility of an Error page An Error JSP will be called.
Java Web Development with NetBeans IDE -- Kai Qian Chapter 5 JavaServer Faces (JSF) Technology.
JavaServer Faces: Sample App + Life Cycle Compiled from Sun TechDays workshops (JSF Basics, Web-Tier Codecamp: JavaServer Faces, Java Studio Creator)
JSP Fundamentals Elements of a JSP Using Beans with JSP Integrating Servlets and JSP.
JAVA SERVER FACES ADITI RAJORIYA UNI – ar2630. POINTS TO BE DISSCUSED WHAT IS JSF? WHY JSF? ARCHITECTURE JSF VERSIONS UI COMPONENTS JSF STRUCTURE AND.
JSF Framework Java Server Faces Presented by Songkran Totiya (6/10/2014)
CSC 2720 Building Web Applications Frameworks for Building Web Applications.
JavaServer Faces (JSF) and Ajax Integration. Agenda 대강의 ( 정말로..) 개요 예제 아키텍트라면..
Chính phủ điện tử TS. Phạm Văn Tính Khoa CNTT, ĐH Nông Lâm TP.HCM
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 41 JavaServer Face.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
Data transfer and type conversion One of the common tasks of the web application domain was moving and converting data from string-based HTTP to the various.
Chapter 6 Chapter 6 Server Side Programming (JSP) Part 1 1 (IS 203) WebProgramming (IS 203) Web Programming.
 Java Server Pages (JSP) By Offir Golan. What is JSP?  A technology that allows for the creation of dynamically generated web pages based on HTML, XML,
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
J2EE/Java EE Apache Tomcat v9 IBM Websphere v8 Redhat JBoss EAP v6 Oracle Weblogic v12 Fusion Web Tier ServletsJSPJSF Business Tier JMXJMSEJB.
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.
Struts 2 Development. Topics  Roles in Struts Development  Control Flow  Actions  Struts 2 Views and Target  Struts 2 Custom Tags  Validation 
Introduction to Java Server Faces (covered topics) ● Reasons to use „Java Server Faces“ ● JSF application structure ● JSF component model ● JSF managed.
Intro to JavaServer Faces Mimi Opkins CECS 493 Fall 2016.
Introduction to JavaServer Faces and the Woodstock UI Components Presenter Name
The Expression Language Syntax
J2EE Lecture 4: Advanced Concepts in JSF
JavaServer Faces: The Fundamentals
JavaServer Faces: It is a server side component based user interface framework. It is used to develop web applications. It provides a well-defined programming.
Presentation transcript:

JavaServer Faces framework

2001 Craig McClanahan is presented that created Struts web framework and based on experience gathered designed JavaServer Faces framework JavaServer Faces2

3 Component-oriented web frameworks

JavaServer Faces4

How HTML form data are retrieved in a servlet public void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {... String age = request.getParameter(“age”); String date = request.getParameter(“date”);... Most data must then be: converted – String must be converted to Date, age must be converted to number validated – age must be positive number JavaServer Faces5

We declaratively define what form field must be bind with what class field Web framework: moves data through the binding automatically performs conversion and validation JavaServer Faces6 Approach taken by modern UI frameworks: data binding

Backing Beans, JavaBeans spec. Class User shown above is called Backing Bean It is non-visual component (do not confuse with JSF components!) “Bean” (i.e. component) because it must satisfy JavaBeans specification requirements JavaBeans specification available at: html html 114 pages Introduction says: "The goal of the JavaBeans APIs is to define a software component model for Java, so that third party ISVs can create and ship Java components that can be composed together into applications by end users." JavaServer Faces7

Shortly about JavaBeans specification Essential JavaBean component‘s parts: Properties read/write, read-only, write-only properties, property introspection, and so on. Methods Usual public Java class methods; means for communication between JavaBean components Constructor without parameters is required (may be empty though)! JavaBean components have their own binary format JAR archives with manifest file JavaServer Faces8

Example of a property public class Person { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; }... } Property name is tuple {name, getName(), setName()} Without setName() we would get read-only property Without getName() we would get write-only property JavaServer Faces9

Bindings in JSF HTML form fields can be bound to JSF backing bean properties HTML form active components (e.g. buttons, links) can be bound to JSF backing bean methods JavaServer Faces10

Example of an JSF application Application consists from two HTML pages The first page allows to enter a number, and as a result outputs squared number Example of declarative validation is shown The second page shows the last calculated result Example of user session and declarative navigation JavaServer Faces11

A backing bean public class Calculator implements Serializable { // Read/write property "number": private int number = 5; public int getNumber() { return number; } public void setNumber(int number) { this.number = number; } // Read-only property "result": private Integer result = null; public Integer getResult() { return result; } // Method to square a number public void square() { result = number * number; } // Method to navigate to the second page public String bye() { return "enough"; } } JavaServer Faces12

The first HTML page – index.xhtml <html lang="en" xmlns=" xmlns:h=" xmlns:p=" JSF calculator JSF calculator <h:inputText id="number" value="#{calculator.number}" required="true" p:type="number" p:placeholder="Enter number"> JavaServer Faces13

The first HTML page – index.xhtml Result: #{calculator.result} <h:commandButton value="Square" actionListener="#{calculator.square}"/> <h:commandButton value="Bye bye" action="#{calculator.bye}" immediate="true"/> JavaServer Faces14

The second HTML page – bye.xhtml <html lang="en" xmlns=" xmlns:h=" The last result Bye bye The last result: #{calculator.result} JavaServer Faces15

Declarative navigation: faces-config.xml /index.xhtml enough /bye.xhtml JavaServer Faces16

JSF request processing phases JavaServer Faces17

JSF request processing phases 1. Restore view – UI component tree gets restored/created on the server side 2. Apply request values – values entered to HTML form fields are being copied to JSF UI components 3. Process validations – JSF UI components validate data supplied to them 4. Update model values – converted and validated data is being copied from UI components to JSF backing beans 5. Invoke application –backing bean’s method is being invoked 6. Render response – renderer traverses through UI component tree and outputs HTML (or other markup) code JavaServer Faces18

Remarks actionListener – executes bound backing bean method, does not participate in navigation (application stays on the same page) action – executes bound backing bean method, participates in navigation (must return String) immediate="true" – if event is marked with this attribute, no converters and validators will be called, model will not be populated with the data from the HTML form JavaServer Faces19

Remarks required="true" – does not allow empty value for a form field requiredMessage –message shown if required field is left empty converterMessage – message shown if conversion is not successful (e.g. String conversion to Integer) validatorMessage – message shown if validation is not successful (e.g. number is out of valid range) JavaServer Faces20

Pass-through elements <html lang="en" xmlns=" xmlns:jsf=" xmlns:f=" JSF Calculator JSF Calculator Number: <input type="number" placeholder="Enter number" required="true" jsf:id="myNumber" jsf:value="#{calculator.number}"> Result: #{calculator.result} Square Bye bye JavaServer Faces21

Some JSF concepts Renderer – Responsible for displaying a UI component and translating a user’s input into the component's value. Renderers can be designed to work with one or more UI components, and a UI component can be associated with many different renderers. Validator – Responsible for ensuring that the value entered by a user is acceptable. One or more validators can be associated with a single UI component. Backing beans – Specialized JavaBeans that collect values from UI components and implement event listener methods. They can also hold references to UI components. Converter – Converts a component’s value to and from a string for display. A UI component can be associated with a single converter. Messages – Information that’s displayed back to the user. Just about any part of the application (backing beans, validators, converters, and so on) can generate information or error messages that can be displayed back to the user. JavaServer Faces22

JavaServer Faces23 Renderer

RenderKit examples Browser Mobile device Telnet JavaServer Faces24

JSF component suites PrimeFaces ( RichFaces ( ICEfaces ( OpenFaces ( TreeTable component example (PrimeFaces): JavaServer Faces25

What’s interesting for an architect JavaServer Faces26