1 Introduction to JavaServerFaces & MyFaces Anudeep Jassal.

Slides:



Advertisements
Similar presentations
MWD1001 Website Production Using JavaScript with Forms.
Advertisements

Web Development with Karsten Schulz Terp-Nielsen Master Principal Sales Consultant Oracle Denmark.
Apache Struts Technology
Tutorial 6 Creating a Web Form
Intermediate Level Course. Text Format The text styles, bold, italics, underlining, superscript and subscript, can be easily added to selected text. Text.
Web applications using JavaServer Faces (JSF) A brief introduction 1JavaServer Faces (JSF)
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.
Struts Basics SSE USTC Qing Ding. Agenda What is and Why Struts? Struts architecture – Controller: Focus of this presentation – Model – View Struts tag.
Java Server Faces Model/View/Controller Design Pattern for Web Development Slides adapted from “Core JavaServer Faces” by Geary and Horstmann and the J2EE.
Objectives:1. Investigate the Web application deployment descriptor 2. Install and deploy Tomcat and struts 3. Design and deploy a struts application Struts.
Tomcat Configuration A Very, Very, Very Brief Overview.
Apache Struts Technology A MVC Framework for Java Web Applications.
ECE356 – Database Systems Lab 1 – Building a Web Project with NetBeans Tiuley Alguindigue Lab Instructor – University of Waterloo, E & CE Dept. Fall 2013.
Java Enterprise Edition Java Web Development Structure of a web project Introduction to Web Applications The first project Introduction to Java Web Development.
Struts 2.0 an Overview ( )
Struts. Agenda Preface Struts and its components An example The architecture required for Struts Applications.
UNIT-V The MVC architecture and Struts Framework.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
Java Server Faces Çağatay Çivici Apache MyFaces Team Member
Pittsburgh Java User Group– Dec Java PureFaces: A JSF Framework Extension.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
CSCI 6962: Server-side Design and Programming Validation Tools in Java Server Faces.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
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.
Basic Struts Architecture Client Server Database Request Response Control View Model Server Struts Framework.
1 Lecture 24 George Koutsogiannakis Spring 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
Java Server Pages Lecture July Java Server Pages Java Server Pages (JSPs) provide a way to separate the generation of dynamic content (java)
CSCI 6962: Server-side Design and Programming Introduction to Java Server Faces.
Java Server Pages A JSP page is a text-based document that contains two types of text: static template data, which can be expressed in any text-based format,
Web applications using JavaServer Faces (JSF) A brief introduction 1JavaServer Faces (JSF)
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–
Fall CIS 764 Database Systems Design L8. Web ….
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
J2EE Overview Web Programming CSCI J2EE multi-tier architecture Servlet: Java class loaded into Web server JSP page: enhanced HTML page that is.
Java Server Faces Introduction Harshavardhan M. Karkar Project Manager Info-Spectrum India Pvt. Ltd.
Java Web Development with NetBeans IDE -- Kai Qian Chapter 5 JavaServer Faces (JSF) Technology.
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)
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
Java Server Pages (JSP)
Chính phủ điện tử TS. Phạm Văn Tính Khoa CNTT, ĐH Nông Lâm TP.HCM
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
CS562 Advanced Java and Internet Application Introduction to the Computer Warehouse Web Application. Java Server Pages (JSP) Technology. By Team Alpha.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
13 Copyright © 2004, Oracle. All rights reserved. Adding Validation and Error Handling.
Chapter 12© copyright Janson Industries Java Server Faces ▮ Explain the JSF framework ▮ SDO (service data objects) ▮ Facelets ▮ Pagecode classes.
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.
 2003 Prentice Hall, Inc. All rights reserved Deploying a Web Application ( may include.war )
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
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.
Model View Controller. MVC is the separation of model, view and controller. It's simply a paradigm; an ideal that you should have in the back of your.
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.
Examples with Java Server Faces (covered topics)
CARA 3.10 Major New Features
Unit 6-Chapter 2 Struts.
Introduction to Struts
JavaServer Faces: The Fundamentals
Presentation transcript:

1 Introduction to JavaServerFaces & MyFaces Anudeep Jassal

2 Topics of Discussion What is JSF? JSF Architecture. How does JSF work. What is MyFaces?

3 What is Java Server Faces?  JSF is a new and upcoming web application framework that accomplishes the MVC paradigm It is similar to Struts but has features and concepts that are beyond those of Struts - especially the component orientation.  Provides set of reusable custom components.  Provides set of JSP tags to access those components.

4 JSF Architecture  JSF follows MVC framework  Model: objects and properties of application  View: Renderers take care of view.  Controller: FacesServlet/ JSF infrastructure defines the flow of the application.

5 How JSF works A form is displayed Form uses and The form is submitted to itself. The bean is instantiated. Listed in the managed-bean section of faces-config.xml The action controller method is invoked. The action method returns a condition. The result page is displayed.

6 Login page

7 Welcome page

8 Example files index.jsp,welcome.jsp – define the login and welcome screens. UserBean.java – manages user data faces-config.xml – configuration file for the application. web.xml – deployment descriptor.

9 JSF Example(index.jsp) … Name: … Password: …

10 index.jsp Tag Libraries: core and html. Core tags are used to perform core actions and display nothing to the user. Html tags are used to render html elements(text, form elements etc) to the user. is a core tag. Loads properties file and makes it value available to variable message.properties file All JSF components must be nested inside core tag.

11 Example (Cntd.) Any attribute value that starts with # and is wrapped in {} is dynamically substituted in #{Message.inputname_header} represents form element Form action is defined in the element. for name field renders a textbox. Required attribute tells the value must be provided by the user. Thus validating the field. Nested core tag provides range validation.

12 UserBean.java public class UserBean { public String getName() {... } public void setName(String newValue) {... } public String getPassword() {... } public void setPassword(String newValue) {... }... }

13 Configuration file (faces-config.xml) <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN" " /index.jsp login /welcome.jsp user com.corejsf.UserBean session

14 Configuration File(Cntd.) faces-config.xml defines how one page will navigate to next. Also specifies managed beans. /index.jsp login /welcome.jsp </navigation-rule page you are currently on. next page to display. value matches the action attribute of the command button of index.jsp

15 Configuration file (Cntd.) Managed bean is the model of the framework. is the name the views use to reference the bean. user is the fully classified name for the bean. com.corejsf.UserBean session

16 Web.xml (Deployment Descriptor) javax.faces.CONFIG_FILES /WEB-INF/faces-config.xml Faces Servlet javax.faces.webapp.FacesServlet 1 Faces Servlet

17 Web.xml (Cntd.) Javax.faces.CONFIG_FILES parameter tells where the JSF configuration file exists. javax.faces.CONFIG_FILES /WEB-INF/examples-config.xml Javax.faces.STATE_SAVING_METHOD specifies where the state must be saved: client or server. javax.faces.STATE_SAVING_METHOD server The servlet-mapping and servlet blocks specify that any URL that ends in a.jsf extension should be redirected through a servlet called javax.faces.webapp.FacesServlet.

18 What is Apache MyFaces? First free open source implementation of JSF. Provides rich set of prefabricated components.

19 MyFaces Component Libraries Tomahawk Original MyFaces component library. Tobago Apache Library now under MyFaces umbrella. Trinidad Originally Oracle ADF components.

20 Using MyFaces Tomahawk Components Add jar files to WEB-INF/lib Tomahawk.jar Commons-fileupload.jar Commons-validator.jar Oro-xxx-jar Import the extended tag library Enable extensions filter Add a filter and two filter mappings in web.xml - Delivers JavaScript code and style sheets. Components which use JavaScript will fail without these entries in web.xml

21 DateDate Component Input Text control for dates. Attributes Value – the Date value. Type – Defines the content type. Date,time or both popupCalendar - If true, button added that pops up JavaScript calendar for input. Default is false

22 t:inputDate example Main JSP page Date: Bean package coreservlets import java.util.*; public class SampleBean { private Date date; public Date getDate() { return(date); } public void setDate(Date date) { this.date = date; }

23 Example (Cntd.) faces-config.xml sample coreservlets.SampleBean request /date.jsp show-date /WEB-INF/results/show-date.jsp Result Page You selected the following date:

24

25 Tabbed Pane Description- for switching panels. Attributes bgColor – the background color of the active tab activeTabStyleClass,inactiveTabStyleClass t:panelTab contains per tab content. HTML goes within Shared content is outside t:panelTab but within t:panelTabbedPane Everything must be inside h:form Non tab content goes outside t:panelTabbedPane

26 Example t:panelTabbedPane Tab 1 Tab 2 Tab 3

27

28 t:inputHTML Inline HTML based word processorword processor

29 Usage

30 JSCookMenu Renders a nested navigation menu.

31 Popup Component Renders a popup which displays on a mouse event.popup

32 Tomahawk Validators Widely used validators validateRegExpr validate validateCreditCard validateEquals

33 validateRegExpr Attributes: pattern – required message - optional Example ZIP Code: <t:validateRegExpr pattern="\d{5}" message="ZIP Code must be 5 digits"/>

34 validate Attributes: no attributes are required Example <t:validate message="Invalid address"/>

35 validateCreditCard Attributes: no attributes are required. You can specify that only Visa, MasterCard etc are acceptable. Example: Credit Card: <t:validateCreditCard message="Invalid credit card number"/>

36 validateEquals(custom validator for equal inputs) Attributes: for: Required message: Optional Example Confirm Credit Card: <t:validateEqual for="card1" message="The two credit card entries do not match"/>

37 Advantages of JSF The big advantage of using JSF is that it provides reusable components. It has drag and drop IDE support. Provides built-in form validation. Provides set of APIs and associated custom tags to create HTML forms that have complex interface.

38 Disadvantages of JSF Bad Documentation Compared to the standard servlet and JSP APIs, JSF has fewer online resources, and many first-time users find the online JSF documentation confusing and poorly organized. Undeveloped tool support There are many IDEs with strong support for standard servlet and JSP technology. Support for JSF is only beginning to emerge, and final level is yet to be determined.

39 References content/presentations/ApacheConAsia2006_MyFaces_Tutorial.pdf m RC3/JSFTools_tutorial.html ng_custom_components.html

40 Questions?