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

Similar documents
JavaServer Faces 2.0

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

Java EE 6: Develop Web Applications with JSF

JSF. What is JSF (Java Server Faces)?

Advanced Web Technologies 8) Facelets in JSF

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

A Red Hat Perspective

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:

Facelets and its use in Web Applications

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

Specialized - Mastering JEE 7 Web Application Development

JSF. JSF and Ajax Basics

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

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

Introduction to Java Server Faces(JSF)

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

Developing Applications with Java EE 6 on WebLogic Server 12c

Oracle Developer Day

Java EE 6 New features in practice Part 2

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

Java TM. JavaServer Faces. Jaroslav Porubän 2008

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

Going Above and Beyond JSF 2 with RichFaces & Seam

Overview. Principal Product Manager Oracle JDeveloper & Oracle ADF

Table of Contents. Introduction... xxi

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

Improve and Expand JavaServer Faces Technology with JBoss Seam

Table of Contents Fast Track to JSF 2

Building Web Applications With The Struts Framework

11.1 Introduction to Servlets

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

Liferay Faces. Reference Documentation ga4

FINALTERM EXAMINATION Spring 2009 CS506- Web Design and Development Solved by Tahseen Anwar

Enterprise Java Unit 1-Chapter 2 Prof. Sujata Rizal Java EE 6 Architecture, Server and Containers

Contents. 1. JSF overview. 2. JSF example

Very short introduction to JavaServer Faces

112. Introduction to JSP

JSF Tools Reference Guide. Version: M5

112-WL. Introduction to JSP with WebLogic

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

Contents at a Glance

JSF & Struts 1, 4, 7, 2, 5, 6, 3 2, 4, 3, 1, 6, 5, 7 1, 4, 2, 5, 6, 3, 7 1, 2, 4, 5, 6, 3, 7

JSF Tools Reference Guide. Version: beta1

sessionx Desarrollo de Aplicaciones en Red EL (2) EL (1) Implicit objects in EL Literals José Rafael Rojano Cáceres

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

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

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

Liferay Faces. Reference Documentation ga2

Vision of J2EE. Why J2EE? Need for. J2EE Suite. J2EE Based Distributed Application Architecture Overview. Umair Javed 1

Integrating Seam and GWT

JAVA COURSES. Empowering Innovation. DN InfoTech Pvt. Ltd. H-151, Sector 63, Noida, UP

Session 21. Expression Languages. Reading. Java EE 7 Chapter 9 in the Tutorial. Session 21 Expression Languages 11/7/ Robert Kelly,

Refactoring to Seam. NetBeans. Brian Leonard Sun Microsystems, Inc. 14o

}w!"#$%&'()+,-./012345<ya

Peter Norrhall. Callista Enterprise AB.

JavaServer Pages and the Expression Language

JSF 2.0: Insight and Opinion

Spring Web Flow Reference Guide

Courses For Event Java Advanced Summer Training 2018

Module 5 Developing with JavaServer Pages Technology

What's New in the Servlet and JavaServer Pages Technologies?

CS506 Web Design & Development Final Term Solved MCQs with Reference

Visual Web Tools Reference Guide. ISBN: Publication date:

C IBM. Developing IBM Lotus Domino Applications- Advanced XPage Design

New Features in EJB 3.1

Université du Québec à Montréal

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

Advanced Web Technology - Java Server Faces

Mastering JavaServer Faces

A Gentle Introduction to Java Server Pages

Ch04 JavaServer Pages (JSP)

Java SE7 Fundamentals

Seam & Web Beans. Pete Muir JBoss, a division of Red Hat.

Fast Track to Java EE 5 with Servlets, JSP & JDBC

Managed Beans III Advanced Capabilities

Distributed Multitiered Application

Oracle 1Z Oracle Application Development Framework 12c Essentials. Download Full Version :

Spring & Hibernate. Knowledge of database. And basic Knowledge of web application development. Module 1: Spring Basics

ADF Code Corner How-to launch a popup upon rendering of a page fragment in a region using JSF 2. Abstract: twitter.

Spring Web Flow Reference Guide

JavaEE Interview Prep

8 JSF, Images, CSS, and JS

JSR-303 Bean Validation. Emmanuel Bernard Doer JBoss, a Division of Red Hat

Advanced Java Programming

Java Server Pages. JSP Part II

Writing Servlets and JSPs p. 1 Writing a Servlet p. 1 Writing a JSP p. 7 Compiling a Servlet p. 10 Packaging Servlets and JSPs p.

For this week, I recommend studying Chapter 2 of "Beginning Java EE 7".

One application has servlet context(s).

Sun Java Studio Creator. Ken Paulsen Staff Engineer Sun Microsystems, Incorporated (Slides by: Craig R. McClanahan)

Oracle 1z Java Enterprise Edition 5 Web Component Developer Certified Professional Exam. Practice Test. Version:

open source community experience distilled

Mastering Oracle ADF Task Flows. Frank Nimphius Principal Product Manager Oracle JDeveloper / ADF

Fast Track to Spring 3 and Spring MVC / Web Flow

Introduction to Web Application Development Using JEE, Frameworks, Web Services and AJAX

Server-side Web Programming

Java- EE Web Application Development with Enterprise JavaBeans and Web Services

JSF 2.0: Insight and Opinion

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

Oracle Retail Accelerators for WebLogic Server 11g

Evaluating a Reference Enterprise Application as a Teaching Tool in a Distributed. Enterprise Computing Class THESIS

Transcription:

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

Agenda JSF 2.0 Overview of New Features Facelets Annotations Composite Components Ajax support

Overview Major change in the release Part of Java Enterprise Edition 6 Platform Simplifies/Streamlines web application development Reusable UI components Well defined and simplified transfer of application data to and from UI Easy state management Simplified event handling model Simplified Custom component creation Two important major changes in JSF 2.0 Annotations Convention used for navigation

Annotations Support Annotations allow to mark POJO as managed beans Annotations makes faces-config.xml optional (replacement!) Marked using @ManagedBean Scope of the bean is also specified using annotations Request - @RequestScoped Session - @SessionScoped Application - @ApplicationScoped Annotations are used for Converters Validators Composite Components..

Annotations and Managed Beans JSF 1.x <managed-bean> <managed-bean-name>userbean</managed-bean-name> <managed-bean-class>com.demo.userbean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> JSF 2.0 package com.demo; //import declarations @ManagedBean @SessionScoped public class UserBean { //code }

Annotations and Managed Beans package com.demo; //imports @ManagedBean(name="regBean") @RequestScoped public class RegisterBean { //code } Usage. <h:inputtext label="emailid" id="emailid" value="#{regbean.email}" size="20" required="true"/>

Navigation using Convention Navigation in JSF 1.x Specified in faces-config.xml <h:commandlink value="next" action="question2"/> <navigation-rule> <from-view-id>/question1.jsp</from-view-id> <navigation-case> <from-outcome>question2</from-outcome> <to-view-id>/question2.jsp</to-view-id> </navigation-case> </navigation-rule>

Navigation using Convention Navigation in JSF 2.0 Two types of Navigation Implicit Navigation Conditional Navigation Implicit Navigation Default navigation model No entry in faces-config.xml Value of action attribute is treated as to-view-id Greatly simplifies navigation Conditional Navigation Set a pre-condition for navigation Pre-condition mandatory for navigation Pre-condition specified using EL

Implicit Navigation <h:commandlink value="next" action="question2"/> The value of the action attribute is treated as the to-view-id. The default navigation handler appends a '/' and.xhtml extension, and navigation proceeds from question1.xhtml to question2.xhtml. In case a bean method is invoked as part of the action, the String values returned by the method are also treated the same way.

Conditional Navigation <navigation-case> <from-action>#{admin.buystock}</from-action> <if>#{user.admin}</if> <to-view-id>/order.xhtml</to-view-id> </navigation-case>

Facelets Facelets view technology Pages are specified using XHTML, files have.xhtml extension Pages are compiled into an abstract syntax component tree - UIComponent hierarchy during runtime Benefits Page templating Faster execution Portable across diverse platforms Libraries supported JSF HTML JSF Core JSF Facelets JSTL Core JSTL Functions

Facelets To use Facelets, parameters to be set in web.xml <context-param> <param-name>javax.faces.default_suffix</param-name> <param-value>.xhtml</param-value> </context-param> <context-param> <param-name>javax.faces.facelets_skip_comments</param-name> <param-value>true</param-value> </context-param>

Composite Components Simplified using Facelets Resources Composite component is a Facelet residing in Resources directory Defined using <composite:interface> <composite:attribute> <composite:implementation>

Creating Custom Component in JSF 2.0 Create a resource library - comp Create a Facelets markup file in the resource library register.xhtml Use a composite component in a Facelets page Use the following namespace: http://java.sun.com/jsf/composite/comp, where comp is the name of the resource library. Refer to the component as comp:register, where comp is the prefix that identifies the above namespace and register is the name of the Facelets file in the resource library.

General Structure of a Composite Component <!-- XHTML DOCTYPE Declaration --> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:composite="http://java.sun.com/jsf/composite"> <! Interface that defines the user contract of the component--> <composite:interface>... </composite:interface> <!-- Implementation that specifies the actual markup--> <composite:implementation>... </composite:implementation> </html>

Composite Component Composite Component attribute can be accessed using #{cc.attrs.attr_name}

Support for Ajax JSF 2.0 supports Ajax integration Two ways to send an Ajax request Using the JavaScript function jsf.ajax.request Using <f:ajax> tag <f:ajax> tag Has the following attributes render, execute, event, onevent <h:inputtext label="email ID" id="emailid" value="#{userbean.email}" size="20" required="true" valuechangelistener="#{userbean.validateemail}"> <f:ajax event="keyup" render="emailresult"/> </h:inputtext>

Bean Validation Bean Validation Annotation @NotNull Constraint Imposed on the element Cannot be null @Min Must be a number whose value must be higher or equal to the specified minimum @Max Must be a number whose value must be lower or equal to the specified maximum @Size Must be between specified minimum and maximum limits @Pattern Must match the specified Java regular expression

JSF 2.0 Bean Validation JSF 2.0, provides built-in support for bean validation Managed bean properties are mapped to UIInput components on the form The JSF implementation can apply the validation constraints on the component's values and capture any error message as FacesMessage @ManagedBean @RequestScoped public class RegisterBean { @Size(min = 1, message = "Please enter the Email") @Pattern(regexp = "[a-za-z0-9]+@[a-za-z0-9]+\\.[a-za-z0-9]+", message = "Email format is invalid.") private String email;.. @Size(min = 1, message = "Please enter a Username") private String username; @NotNull(message = "Please enter Date of birth") private Date dob;. }

Resources More details on JSF 2.0 is available at: http://www.developer.com/features/article.php/3867851/jsf-20-views- Hello-Facelets-Goodbye-JSP.htm http://www.developer.com/java/web/article.php/3868226/jsf-20- Annotations-New-Navigation-Eliminate-XML-Configuration.htm http://www.developer.com/java/web/article.php/3869281/jsf-20- Creating-Composite-Components.htm http://www.developer.com/java/web/article.php/3870686/inside-jsf- 20s-Ajax-and-HTTP-GET-Support.htm http://www.developer.com/features/article.php/52691_3880151_1/jsf- 20-Bean-Validation-and-Dependency-Injection.htm Authored by Sangeetha S, KL Nitin, Ananya S

Thank You! 2010 Infosys Technologies Limited