Zongwei Yuan 1. Why JavaServer Faces Model-view-controller (MVC) architecture Easy to Drop components onto a web page by adding component tags. Bind components.

Slides:



Advertisements
Similar presentations
JSF Portlet Backing Beans and UI Components Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in.
Advertisements

Web Development with Karsten Schulz Terp-Nielsen Master Principal Sales Consultant Oracle Denmark.
Apache Struts Technology
A Blackboard Building Block™ Crash Course for Web Developers
Expression Language Lec Umair Javed©2006 Generating Dynamic Contents Technologies available  Servlets  JSP  JavaBeans  Custom Tags  Expression.
Web applications using JavaServer Faces (JSF) A brief introduction 1JavaServer Faces (JSF)
Internet Technologies 1 Master of Information System Management Java Server Faces Model/View/Controller Design Pattern for Web Development Slides.
WEB1P servintro1 Introduction to servlets and JSP Dr Jim Briggs.
DT211/3 Internet Application Development
Java Server Faces Model/View/Controller Design Pattern for Web Development Slides adapted from “Core JavaServer Faces” by Geary and Horstmann and the J2EE.
Apache Struts Technology A MVC Framework for Java Web Applications.
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.
Struts 2.0 an Overview ( )
UNIT-V The MVC architecture and Struts Framework.
De-mystifying JavaServer™ Faces
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.
WaveMaker Visual AJAX Studio 4.0 Training Studio Overview.
Java Server Faces Çağatay Çivici Apache MyFaces Team Member
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Pittsburgh Java User Group– Dec Java PureFaces: A JSF Framework Extension.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
1 Introduction to JavaServerFaces & MyFaces Anudeep Jassal.
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.
CSE446 S OFTWARE Q UALITY M ANAGEMENT Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi Orhan Başar Evren.
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.
Web applications using JavaServer Faces (JSF) A brief introduction 1JavaServer Faces (JSF)
CSCI 6962: Server-side Design and Programming Java Server Faces Components and Tags.
JSF Introduction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
® IBM Software Group © 2007 IBM Corporation JSP Expression Language
Stanisław Osiński, 2002JSP – A technology for serving dynamic web content Java Server Pages™ A technology for serving dynamic web content Stanisław Osiński,
Fall CIS 764 Database Systems Design L8. Web ….
JSTL Lec Umair©2006, All rights reserved JSTL (ni) Acronym of  JavaServer Pages Standard Tag Library JSTL (like JSP) is a specification, not an.
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.
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.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
1 Web Programming with Servlets & JSP ASSIGNMENT GUIDELINE.
WebObjects Matt Aguirre Lally Singh. What Is It? A Java based development platform specifically designed for database-backed web applications.
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.
Chapter 12© copyright Janson Industries Java Server Faces ▮ Explain the JSF framework ▮ SDO (service data objects) ▮ Facelets ▮ Pagecode classes.
JavaServer Faces framework Craig McClanahan is presented that created Struts web framework and based on experience gathered designed JavaServer.
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.
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.
Struts 2 Development. Topics  Roles in Struts Development  Control Flow  Actions  Struts 2 Views and Target  Struts 2 Custom Tags  Validation 
Standard JSF Tags Mimi Opkins CECS 493 Fall 2016.
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.
Examples with Java Server Faces (covered topics)
Event Handling Mimi Opkins CECS 493 Fall 2016.
JSP (Java Server Page) JSP is server side technology which is used to create dynamic web pages just like Servlet technology. This is mainly used for implementing.
Unit 6-Chapter 2 Struts.
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:

Zongwei Yuan 1

Why JavaServer Faces Model-view-controller (MVC) architecture Easy to Drop components onto a web page by adding component tags. Bind components on a page to server-side data. Wire component-generated events to server-side application code. Save and restore application state beyond the life of server requests. Reuse and extend components through customization. Provide important services: Data conversion Validation and error handling Internationalization Custom component Alternative render Tool support Extensibility Install JSF Jsf-api.jar, jsf-impl.jar and jstl.jar 2

Sample JSF File index.jsp A Simple JavaServer Faces Application Please enter your name and password Name: Password:

Managed bean Definition Bean Properties T getFoo() void setFoo(T newValue) Value binding expression Bean scope Request Session application Backing beans 4

Configure Beans WEB-INF/web.xml javax.faces.CONFIG_FILES WEB-INF/navigation.xml,WEB-INF/faces-configure.xml... WEB-INF/faces-configure.xml user com.corejsf.UserBean session In faces-configure.xml we can setting property values initializing lists and maps collection. changing bean definitions (for backing bean) string conversions (convert text value to different data type) 5

Value Binding expressions (1) Value binding Reference to implicit objects header headerValues param paramValues cookie initParam requestScope sessionScope applicationScope facesContext view 6

Value binding expressions (2) Immediate and deferred evaluation expression (${ } and #{ }) Composite expressions: arithmetic operators + - * / % relational operators >= == != logical operators && || ! the “empty”, “not” operator. the ternary ?: selection operator Method binding Attributes can bind to method: action validator actionListener valueChangeListener 7

Navigation Navigation rules In JSF file: In faces-configure.xml: /index.jsp login /welcome.jsp Dynamic navigation #{quiz.answerAction} 8

Load Property Bundle localization 9

Standard JSF Tags Core library tag total 18 HTML library tag total 25 Such as:... 10

Core Tags view Creates the top-level view subviewCreates a subview of a view facetAdds a facet to a component attributeAdds an attribute (key/value) to a component paramAdds a parameter to a component actionListenerAdds an action listener to a component valueChangeListenerAdds a valuechange listener to a component converterAdds an arbitrary converter to a component convertDateTimeAdds a datetime converter to a component convertNumberAdds a number converter to a component validatorAdds a validator to a component validateDoubleRangeValidates a double range for a component's value validateLengthValidates the length of a component's value validateLongRangeValidates a long range for a component's value loadBundleLoads a resource bundle, stores properties as a Map selectitemsSpecifies items for a select one or select many component selectitemSpecifies an item for a select one or select many component verbatim Adds markup to a JSF page 11

HTML Tags formHTML form inputTextSingle-line text input control inputTextareaMultiline text input control inputSecretPassword input control inputHiddenHidden field outputLabelLabel for another component for accessibility outputLinkHTML anchor outputFormatLike outputText, but formats compound messages outputTextSingle-line text output commandButtonButton: submit, reset, or pushbutton commandLinkLink that acts like a pushbutton messageDisplays the most recent message for a component messagesDisplays all messages graphicImageDisplays an image selectOneListboxSingle-select listbox selectOneMenuSingle-select menu selectOneRadioSet of radio buttons selectBooleanCheckboxCheckbox selectManyCheckboxSet of checkboxes selectManyListboxMultiselect listbox selectManyMenuMultiselect menu panelGridHTML table panelGroupTwo or more components that are laid out as one dataTableA feature-rich table control columnColumn in a dataTable 12

Tag Attribute Shared, unique, converter, validator, values Html and dhtml event attribute Action and actionListener Rendering and style 13

JSTL tags Reference Tags Core Functions Database XML I18N (format) Examples 14

h:form Has most of HTML and DHTML event attributes Has no method and action Use only post method Navigation submitted by components Works with JavaScript 15

Textfield and Textarea immediate, required, redisplay attribute 16

Buttons and links Action and actionListener attribute Immediate attribute 17

Message tag and Some special attributes: globalOnly for showDetail errorClass Information Warning Error fatal 18

Data table (1) ,

Data table (2) Data – one of follow types: Array ArrayDataModel java.util.List ListDataModel java.sql.ResultSet ResultDataModel javax.servlet.jsp.jstl.sql.Result ResultSetDataModel javax.faces.model.DataModel ScalarDataModel Header and footer facet Scrolling scroll bar. use pageant. use page widget 20

Conversion and Validation Standard Conversion tag Use converter attribute 21

Using standard validators Built-in validation Checking the length of a string Checking limits for a numerical value Checking that a value has been supplied Validation tag f:validateDoubleRange f:validateLongRange f:validateLength Overwrite messages create your own message bundle property overwrite message property value on the same key update configure.xml file to load the new bundle “required” attribute Bypass validation 22

Converter Object getAsObject(FacesContext context, UIComponent component, String newValue) String getAsString(FacesContext context, UIComponent component, Object value) Validator Implement interface javax.faces.validator.Validator Register in configure.xml Validate with bean method public class PaymentBean {... public void luhnCheck(FacesContext context, UIComponent component, Object value) {... } Implement custom converter and validator 23

Event Handling (1) JSF support 3 kind events: value change events action events phase events Request life cycle Restore View Apply Request Values Process Validations Update Model Values Invoke Application Render Response action an actionListener attribute ActionListener – for user interfaces logic and interface info (first) Action – for business logic (second triggered) 24

Event Handling (2) Use action listener tag f:actionListener and f:valueChangeListener Listener implements public class CountryListener implements ValueChangeListener { private static final String US = "United States"; public void processValueChange(ValueChangeEvent event) { FacesContext context = FacesContext.getCurrentInstance(); if (US.equals((String) event.getNewValue())) context.getViewRoot().setLocale(Locale.US); else context.getViewRoot().setLocale(Locale.CANADA); } 25

Event Handling (3) “immediate” to bypass other component validation Add immediate attribute Calling FacesContext.renderResponse() Phase event listener In configure.xml com.corejsf.PhaseTracker Listener implements interface javax.faces.event.PhaseListener PhaseId getPhaseId() void afterPhase(PhaseEvent) void beforePhase(PhaseEvent) 26

MyFaces project Introduction Compatible with tomcat and easy to deploy Rich debugging and diagnostic info Rich components (pagination) Provide eclipse plug-in Sub project Tomahawk Trinidad ExtVal (Extensions Validator) Installation and deployment Facelets Template, composite component 27

RBAC web app on MyFaces Database access application User View Source code example 28