Mastering JavaServer Faces

Similar documents
Java EE 6: Develop Web Applications with JSF

A Red Hat Perspective

Developing Applications with Java EE 6 on WebLogic Server 12c

JSF. What is JSF (Java Server Faces)?

Oracle Developer Day

Ajax and JSF: Natural Synergy

Oracle - Developing Applications for the Java EE 7 Platform Ed 1 (Training On Demand)

JSF. JSF and Ajax Basics

Very short introduction to JavaServer Faces

JavaServer Faces Technology, AJAX, and Portlets: It s Easy if You Know How!

E Eclipse debugging a JSF application, 25 downloading, 2 installing, 2 launching JBoss in, 3

More reading: A series about real world projects that use JavaServer Faces:

Case Study: Big Lots Store Inventory Management

Seam 3. Pete Muir JBoss, a Division of Red Hat

Advanced Web Technologies 8) Facelets in JSF

Type of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes

A Closer Look at XPages in IBM Lotus Domino Designer 8.5 Ray Chan Advisory I/T Specialist Lotus, IBM Software Group

Courses For Event Java Advanced Summer Training 2018

AIM. 10 September

Oracle Developer Day

Improve and Expand JavaServer Faces Technology with JBoss Seam

CHAPTER 2 LIFECYCLE AND PAGE NAVIGATION

Oracle Fusion Middleware 11g: Build Applications with ADF I

JSF Tags. This tutorial will cover a number of useful JSF tags. For a complete listing of available JSF tags consult the Oracle documentation at:

AJAX in Apache MyFaces A New Approach To Web Applications

JSF Tools Reference Guide. Version: M5

If you wish to make an improved product, you must already be engaged in making an inferior one.

Example jsf-cdi-and-ejb can be browsed at

JSF 2.0: Insight and Opinion

JSF 2.0: Insight and Opinion

ADF Code Corner How-to bind custom declarative components to ADF. Abstract: twitter.com/adfcodecorner

Overview. Principal Product Manager Oracle JDeveloper & Oracle ADF

Anno Accademico Laboratorio di Tecnologie Web. Esempio di progetto

Session 24. Introduction to Java Server Faces (JSF) Robert Kelly, Reading.

Java SE7 Fundamentals

Oracle ADF: The technology behind project fusion. Lynn Munsinger Principal Product Manager Application Development Tools Oracle Corporation

Oracle Fusion Middleware 11g: Build Applications with ADF I

JBoss Seam Integration with intent to use. Dan Allen Software Consultant Author, Seam in Action

JSF page, 76 manage bean, 76 named status, 78 request, 75 start facet, 78 starttext and stoptext attributes, 75 style attribute, 77

Oracle Fusion Middleware 11g: Build Applications with ADF Accel

MASTERS COURSE IN FULL STACK WEB APPLICATION DEVELOPMENT W W W. W E B S T A C K A C A D E M Y. C O M

Module 3 Web Component

Portlet Application Development Webinar exercise using JSF and JPA with Rational Application Developer

Generating a JavaServer Faces 2.0 CRUD Application from a Database

JavaServer Faces 2.0. Sangeetha S E-Commerce Research Labs, Infosys Technologies Ltd

Introduction to Java Server Faces(JSF)

Seam. Pete Muir JBoss, a Division of Red Hat.

Java TM. JavaServer Faces. Jaroslav Porubän 2008

Advanced Graphics Components Using JavaServer Faces Technology. Christophe Jolif Architect ILOG S.A.

SOFTWARE DEVELOPMENT SERVICES WEB APPLICATION PORTAL (WAP) TRAINING. Intuit 2007

Building Web Applications With The Struts Framework

JavaServer Faces 2.0

Financial. AngularJS. AngularJS.

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

JSF Tools Reference Guide. Version: beta1

Financial. AngularJS. AngularJS. Download Full Version :

Rich Web UI made simple Building Data Dashboards without Code

Contents. 1. JSF overview. 2. JSF example

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Java EE 6 - Update Harpreet Singh GlassFish Portfolio Product Manager

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved.

Application Integration with WebSphere Portal V7

Oracle Middleware 12c: Build Rich Client Applications with ADF Ed 1 LVC

Visual Web Tools Reference Guide. ISBN: Publication date:

CMP 436/774. Introduction to Java Enterprise Edition. Java Enterprise Edition

Table of Contents Fast Track to JSF 2

Introduction to Dreamweaver CS4:

New Fire system. The student assignment submission system for Computer Science Department of Chalmers. Master s Thesis in the Master Degree Program,

JSF: The "h" Library Originals of Slides and Source Code for Examples:

Seam. Pete Muir JBoss, a Division of Red Hat.

Delivery Options: Attend face-to-face in the classroom or via remote-live attendance.

Copyright Descriptor Systems, Course materials may not be reproduced in whole or in part without prior written consent of Joel Barnum

<Insert Picture Here> Advanced ADF Faces. Frank Nimphius Principal Product Manager

Liferay Faces. Reference Documentation ga2

J2EE - Version: 25. Developing Enterprise Applications with J2EE Enterprise Technologies

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. RichFaces

JSF: Introduction, Installation, and Setup

Maturing your security with Seam. Dan Allen Senior Software Engineer JBoss, a division of Red Hat

open source community experience distilled

04/29/2004. Step by Step Guide for Building a simple JSF Application (Guess a Number) - V1.0

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

Delivery Options: Attend face-to-face in the classroom or remote-live attendance.

Oracle Application Development Framework Overview

Developing Web Applications using JavaServer Faces

Specialized - Mastering JEE 7 Web Application Development

Shale and the Java Persistence Architecture. Craig McClanahan Gary Van Matre. ApacheCon US 2006 Austin, TX

Essentials on Performant JavaServer Faces Apps. Client Versus Server Side

2007 Marty Hall Marty Hall. 5 J2EE training: Marty Hall Marty Hall

Delivering Rich Internet Applications with Ajax4jsf

Full Stack Web Developer

<Insert Picture Here>

Maturing your application s security with Seam Security. Dan Allen Senior Software Engineer JBoss, by Red Hat

Java SE 8 Fundamentals

XPages development practices: developing a common Tree View Cust...

Building the Enterprise

CIS 764 Tutorial: Log-in Application

UI Course HTML: (Html, CSS, JavaScript, JQuery, Bootstrap, AngularJS) Introduction. The World Wide Web (WWW) and history of HTML

JSF: The Ajax4jsf Library

CHAPTER 9: Super Jumper: A 2D OpenGL ES Game

The biggest advantage of the JSF technology is its flexible, extensible component model, which includes: An extensible component API for the usual

Transcription:

Mastering JavaServer Faces Bryan Basham Software Alchemist basham47@gmail.com http://www.linkedin.com/in/softwarealchemist Bryan Basham Mastering JavaServer Faces Slide 1

Topics Mind Map Introduction to JSF Roll Your Own JSF Fundamentals Mastering JSF Other tools MyFaces & Tomahawk RichFaces & AJAX4JSF Bryan Basham Mastering JavaServer Faces Slide 2

Web UI Architecture Concerns Client Server........................... UI Code Bryan Basham Mastering JavaServer Faces Slide 3

Client-side Technologies Structure XHTML (or HTML v4.01) Presentation Cascading Style Sheets (CSS) Behavior JavaScript (formally: ECMAScript 262 v3) DOM API specification JS objects (and JSON) for data models Open source frameworks Bryan Basham Mastering JavaServer Faces Slide 4

Server-side Technologies Structure JSF for components (UI widgets) JSP (or other) for layout of component tree Behavior JSF component event model OO programming for data model Open source implementations, frameworks, and component libraries Bryan Basham Mastering JavaServer Faces Slide 5

Separation of Concerns conversion Client Data invoke Data Server........................... Behavior enhanc e Presentation UI Code Behavior select next view style / layout Structure generate Structure Bryan Basham Mastering JavaServer Faces Slide 6

Why JavaServer Faces? Third generation Java-Web technology. Closer to traditional UI development: component-based event-driven Standards-based architecture Open source community Bryan Basham Mastering JavaServer Faces Slide 7

The JSF Stack My Webapp Ajax and other control new UI widgets...and other facilities EL tags request/ response Component Frameworks JavaServer Faces Servlet / JavaServer Pages validation conversion components actions Bryan Basham Mastering JavaServer Faces Slide 8

JSF and Web Standards JSF supports other Web standards XHTML, for structure CSS, for presentation JavaScript, for client-side behavior Use JSF libraries that facilitate client-side Web standards The gotcha... JSF embeds JavaScript into the page Bryan Basham Mastering JavaServer Faces Slide 9

Topics Mind Map Introduction to JSF Roll Your Own JSF Fundamentals Mastering JSF Other tools MyFaces & Tomahawk RichFaces & AJAX4JSF Bryan Basham Mastering JavaServer Faces Slide 10

JSF Life Cycle Web Container........................... renders view POST form data renders view JSF request a view InputText ViewRoot Form CmdLink... creates comp. tree extracts data binds data perform action(s) <jsp>...... </jsp> Backing Bean select next view creates comp. tree <jsp>...... </jsp> Bryan Basham Mastering JavaServer Faces Slide 11

JSF Life Cycle Faces Servlet execute render Lifecycle RESTORE VIEW APPLY REQ VALUES PROCESS VALIDATIONS UPDATE MODEL PROCESS APPLICATION RENDER RESPONSE dispatch <jsp>...... </jsp> restorestate processdecodes processvalidations processupdates processapplication dostart doend savestate UICompTag encodebegin existing component tree InputText encodechildren encodeend ViewRoot Form... CmdLink new component tree Bryan Basham Mastering JavaServer Faces Slide 12

Data Conversion All HTTP request data are strings. Rich apps require rich data simple non-string data: numbers, Boolean values, IP addresses, money, credit card # complex data: structures, objects, entities with relationships The JSF Converter interface: The getasobject method The getasstring method Bryan Basham Mastering JavaServer Faces Slide 13

Data Conversion JSF 172.20.30.42 current value getasstring() The HTML form is rendered with the current value of the ipaddress= 172.20.30.42 The user modifies the value and submits the form: ipaddress= 172.20.30.47 Ipv4Address Converter getasobject() new value 172.20.30.47 Bryan Basham Mastering JavaServer Faces Slide 14

Field Validation Allows field validation checks after data conversion Option #1: call a method on a backing bean <c:textfield id="ipaddress" value="#{editintf.interface.ipaddress}" required="true" converterid="converter.ipv4address" validator="#{editintf.validateipaddress}" /> Option #2: invoke a validator object <c:textfield id="number" value="#{bean.mynumber}" required="true"> <f:validatelongrange minimum="10" maximum="100" /> </c:textfield> Bryan Basham Mastering JavaServer Faces Slide 15

Field Validation JSF Ipv4Address Converter getasobject() gets stored in the UI component for further processing by the life cycle new value 172.20.30.47 validate(...) UIInput validateipaddress(...) a validation error sends the form back to the user with an error message. Backing Bean Bryan Basham Mastering JavaServer Faces Slide 16

Application Actions Action components UICommand (abstract), HtmlCommandLink, and HtmlCommandButton Example: <h:commandbutton value="submit" actionlistener="#{mybean.dothis}" /> Invokes the dothis method of your backing bean when the user clicks the button Bryan Basham Mastering JavaServer Faces Slide 17

Application Actions click Button........................... JSF broadcast(...) HtmlCommand Button invoke: dothis() Backing Bean Bryan Basham Mastering JavaServer Faces Slide 18

Topics Mind Map Introduction to JSF Roll Your Own JSF Fundamentals Mastering JSF Other tools MyFaces & Tomahawk RichFaces & AJAX4JSF Bryan Basham Mastering JavaServer Faces Slide 19

MyFaces is an implementation of the JSF spec. is an open source tool from Apache provides the standard set of UI widgets also includes several additional component libraries: Tomahawk Trinidad Tobago Orchestra Bryan Basham Mastering JavaServer Faces Slide 20

Standard Widget Set Output: f:view, h:outputtext, h:graphicimage, Table: h:datatable, h:column Forms: h:form, h:outputlabel, h:inputtext/secret/textarea/... h:selectbooleancheckbox h:selectonelistbox/menu/radio h:selectmanylistbox/menu/checkbox Layout: h:panelgrid, h:panelgroup Bryan Basham Mastering JavaServer Faces Slide 21

SelectOneMenu: Screen Shot Bryan Basham Mastering JavaServer Faces Slide 22

SelectOneMenu: JSP <div id="exam_select"> <div> <h:outputlabel for="exam_type_select">exam category:</h:outputlabel> <h:selectonemenu value="#{exameditor.categoryoid}" id="exam_type_select"> <f:selectitems value="#{exameditor.categoryselectitems}" /> </h:selectonemenu> </div> <div> <h:outputlabel for="exam_name_select">exam title:</h:outputlabel> <h:selectonemenu value="#{exameditor.examoid}" id="exam_name_select"> <f:selectitems value="#{exameditor.examselectitems}" /> </h:selectonemenu> </div> <div class="button"> <h:commandlink action="#{exameditor.viewexam}"><span>view exam</span></h:commandlink> </div> <div class="button"> <h:commandlink action="#{exameditor.editexam}" immediate="false"><span>edit exam</span></h:commandlink> </div> </div> Bryan Basham Mastering JavaServer Faces Slide 23

SelectOneMenu: Backing Bean public Long getcategoryoid() { return categoryoid; } public void setcategoryoid(long oid) { this.categoryoid = oid; } public List<SelectItem> getcategoryselectitems() { List<Category> categories = this.catsvc.getallcategories(this.em); List<SelectItem> result; result = new ArrayList<SelectItem>(categories.size() + 1); result.add(new SelectItem("0", "Select an exam category...")); for ( Category cat : categories ) { SelectItem item = new SelectItem(cat.getId(), cat.gettitle()); result.add(item); } return result; } Bryan Basham Mastering JavaServer Faces Slide 24

Tomahawk Library Compatible with MyFaces and Mojarra (RI) Includes the forceid attribute Provides a Tiles-like facility Provides additional validators: email, credit card, regexp matching Additional UI widgets Bryan Basham Mastering JavaServer Faces Slide 25

Tomahawk Components List: t:datalist Table: t:datatable, t:datascroller, t:newspapertable, t:schedule Input: t:inputdate, t:inputfileupload, t:inputhtml,... Layout: t:panellayout, t:paneltabbedpane, t:panelstack, t:collapsiblepanel Document: t:document/body/head, t:stylesheet Bryan Basham Mastering JavaServer Faces Slide 26

Trinidad Library Partial page refresh (PPR) Client-side converters and validators Advanced client-side dialog boxes Advanced navigation tools/components File upload Additional UI widgets Bryan Basham Mastering JavaServer Faces Slide 27

Trinidad Components Table: similar to UIData supports paging, sorting, multiple item selection Tree: simple tree and tree-table Charts: many types: pie, bar, scatter plot, and so on generates SVG graphics Bryan Basham Mastering JavaServer Faces Slide 28

Tobago Library Styling by use of themes Built-in I18N / L10N support Controls: table tree sheet tab panel Bryan Basham Mastering JavaServer Faces Slide 29

Topics Mind Map Introduction to JSF Roll Your Own JSF Fundamentals Mastering JSF Other tools MyFaces & Tomahawk RichFaces & AJAX4JSF Bryan Basham Mastering JavaServer Faces Slide 30

RichFaces Library Built-in support for Ajax Skinnable styles Rich component development kit Resource packaging Dynamic resources (e.g. building button icons on the fly) Bryan Basham Mastering JavaServer Faces Slide 31

RichFaces Components Layout: a4j:page, a4j:loadstyle, a4j:loadscript, a4j:include UI widgets: rich:calendar, rich:combobox, Tables: rich:datatable, rich:datascroller, rich:datafilterslider, sorting, filtering Lists: ordered, unordered, definitions Other: drag-n-drop support, effects, panels, trees, and a whole lot more Bryan Basham Mastering JavaServer Faces Slide 32

Ajax Support Forms: form submittal via Ajax; rerender portion of screen Triggers: Periodic: a4j:poll, a4j:repeat Events: a4j:support JSF: rich:ajaxvalidator Most components have built-in Ajax support Bryan Basham Mastering JavaServer Faces Slide 33

OnChange: JSP <div id="exam_select"> <div> <h:outputlabel for="exam_type_select">exam category:</h:outputlabel> <h:selectonemenu value="#{exameditor.categoryoid}" id="exam_type_select"> <f:selectitems value="#{exameditor.categoryselectitems}" /> <a4j:support event="onchange" actionlistener="#{exameditor.findexams}" rerender="exam_name_select" /> </h:selectonemenu> </div> <div> <h:outputlabel for="exam_name_select">exam title:</h:outputlabel> <h:selectonemenu value="#{exameditor.examoid}" id="exam_name_select"> <f:selectitems value="#{exameditor.examselectitems}" /> </h:selectonemenu> </div>... </div> Bryan Basham Mastering JavaServer Faces Slide 34

OnChange: Backing Bean public void findexams() { this.category = catsvc.getcategorybyid(this.categoryoid, this.em); if ( this.category!= null ) { this.exams = this.category.getexams(); } } public List<SelectItem> getexamselectitems() { List<SelectItem> result; if ( this.exams == null this.exams.size() == 0 ) { result = new ArrayList<SelectItem>(1); result.add(new SelectItem("0", "First select a category above.")); } else { result = new ArrayList<SelectItem>(this.exams.size() + 1); result.add(new SelectItem("0", "Select an exam...")); for ( CertificatonExam e : this.exams ) { SelectItem item = new SelectItem(e.getId(), e.gettitle()); result.add(item); } } return result; } Bryan Basham Mastering JavaServer Faces Slide 35

Topics Mind Map Introduction to JSF Roll Your Own JSF Fundamentals Mastering JSF Other tools MyFaces & Tomahawk RichFaces & AJAX4JSF Bryan Basham Mastering JavaServer Faces Slide 36

Other component libraries JSF has broad support and rich community See JSFCentral.org See JSF Forum on java.net There are many open source and COTS libraries Bryan Basham Mastering JavaServer Faces Slide 37

Facelets Built as a replacement for JSP rendering, due to limitations in JSF v1.1 eliminates the need for f:verbatim blocks not really needed in JSF v1.2 Support for tiling, ie. view composition Support for template-based component creation Bryan Basham Mastering JavaServer Faces Slide 38

Seam Integration between UI and Business tiers: JSF <=> EJB3 Use of annotations simplifies complex deployment descriptors Works well with Ajax and Ajax-enabled JSF libraries such as RichFaces Conversational scope Bryan Basham Mastering JavaServer Faces Slide 39

Topics Mind Map Introduction to JSF Roll Your Own JSF Fundamentals Mastering JSF Other tools MyFaces & Tomahawk RichFaces & AJAX4JSF Bryan Basham Mastering JavaServer Faces Slide 40

Building Components Several open source libraries provide rich APIs for building components MyFaces RichFaces Consider the need to inject componentspecific resources styles JavaScript media Bryan Basham Mastering JavaServer Faces Slide 41

Q & A Introduction to JSF Roll Your Own JSF Fundamentals Mastering JSF Other tools MyFaces & Tomahawk RichFaces & AJAX4JSF Bryan Basham Mastering JavaServer Faces Slide 42

Resources JavaServer Faces in Action (Manning) JavaServer Faces: java.sun.com java.net JSF Spec (JSR #252) JSFCentral.org JSF tutorials Component Libraries: MyFaces (for JSF v1.2) RichFaces Other tools: Facelets Seam Framework Bryan Basham Mastering JavaServer Faces Slide 43