A Red Hat Perspective

Similar documents
Java EE 6: Develop Web Applications with JSF

Going Above and Beyond JSF 2 with RichFaces & Seam

Mastering JavaServer Faces

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

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

Improve and Expand JavaServer Faces Technology with JBoss Seam

JSF. What is JSF (Java Server Faces)?

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:

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

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

JSF 2.0: Insight and Opinion

Facelets and its use in Web Applications

JSF. JSF and Ajax Basics

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

Ajax and JSF: Natural Synergy

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

Advanced Web Technologies 8) Facelets in JSF

Java EE 6 New features in practice Part 2

JavaServer Faces 2.0

JSF 2 and beyond: Keeping progress coming

JSF 2.0: Insight and Opinion

Contents. 1. JSF overview. 2. JSF example

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

Oracle Developer Day

Contents at a Glance

Developing Applications with Java EE 6 on WebLogic Server 12c

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

What s new in Spring Web Flow 2.0

Introduction to Java Server Faces(JSF)

Java EE 6 - Update Harpreet Singh GlassFish Portfolio Product Manager

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

Oracle Developer Day

3.2 Example Configuration

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

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

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

Very short introduction to JavaServer Faces

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

AJAX in Apache MyFaces A New Approach To Web Applications

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

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

Oracle Fusion Middleware 11g: Build Applications with ADF I

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

Courses For Event Java Advanced Summer Training 2018

Specialized - Mastering JEE 7 Web Application Development

JSF: Introduction, Installation, and Setup

Oracle Fusion Middleware 11g: Build Applications with ADF Accel

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

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

Generating a JavaServer Faces 2.0 CRUD Application from a Database

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

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

Hands-on Development of Web Applications with Java EE 6

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

8 JSF, Images, CSS, and JS

Visual Web Tools Reference Guide. ISBN: Publication date:

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

Oracle Fusion Middleware 11g: Build Applications with ADF I

JBoss SOAP Web Services User Guide. Version: M5

CHAPTER 2 LIFECYCLE AND PAGE NAVIGATION

JSR-286: Portlet Specification 2.0

Liferay Faces. Reference Documentation ga2

JSF Tools Reference Guide. Version: M5

Table of Contents. Introduction... xxi

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

Spring Web Flow Reference Guide

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

open source community experience distilled

Apache MyFaces CODI. Mark Struberg, INSO TU-Vienna

6/13/2012. Sneak Preview: Oracle JDeveloper 12c New Features. Frank Nimphius Senior Principal Product Manager Oracle Development Tools

Evaluation of State-of-the-Art resource handling in JavaServer Faces based web applications and development of an enhanced resource handler for JSF 2.

Liferay Faces. Reference Documentation ga4

Building Web Applications With The Struts Framework

Spring Web Flow Reference Guide

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

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

Implementing a Numerical Data Access Service

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.

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

Struts: Struts 1.x. Introduction. Enterprise Application

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

1 Markus Eisele, Insurance - Strategic IT-Architecture

XAP: extensible Ajax Platform

web.xml Deployment Descriptor Elements

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

Managed Beans III Advanced Capabilities

Integrating Seam and GWT

Advanced Web Systems 4- PORTLET API specifications (JSR 286) A. Venturini

PGT T3CHNOLOGY SCOUTING. Google Webtoolkit. JSF done right?

JavaServer Faces Specification

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

Java SE7 Fundamentals

Community Participation in the JCP Program: a winning combination November 2012

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

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

Java EE Application Assembly & Deployment Packaging Applications, Java EE modules. Model View Controller (MVC)2 Architecture & Packaging EJB Module

JSR Review Process. May Patrick Curran, Mike Milinkovich, Heather Vancura, Bruno Souza

1Z Java EE 6 Web Component Developer Certified Expert Exam Summary Syllabus Questions

Tapestry. Code less, deliver more. Rayland Jeans

Transcription:

TITLE JSR-314: SLIDE: JavaServer HEADLINE Faces 2.0 Presenter A Red Hat Perspective name Title, Red Hat Date Dan Allen Senior Software Engineer, RedHat JSR-314 Expert Group Member October 8, 2009 1

Roadmap Background What s New? Red Hat s Contributions Community 2

The JSF Story Introduced in 2004 as Java EE standard Developing using the Java Community Process (JCP) JSR-127 JSF 1.0 and 1.1 JSR-252 JSR 1.2, Java EE 5 technology JSR-314 JSF 2.0, Java EE 6 technology Two open source implementations Mojarra JSF RI Apache MyFaces Strong ecosystem of components 3

Goals JavaServer Faces is a standard user interface (UI) framework for developing Java EE web applications APIs for creating user interface (UI) components A default set of UI components Custom tag libraries for adding UI components to a view A server-side event model Managed beans (state management) Unified EL integration 4

JSR-314 (JSF 2.0) Mission Many great ideas Ideas extend from the specification No standard specification to ensure compatibility Harvest ideas and align them with Java EE platform 5

Roadmap Background What s New? Red Hat s Contributions Community 6

What s New in JSF 2? View Declaration Language and Facelets 2* Composite Components System Events Enhanced Navigation** GET Support** Bean Validation** Proper Error Handling* Project Stages First-class JavaScript and Ajax Support* Component Behaviors* Resource Handling Delta State Saving Tree Visiting Annotation-based Configuration Additional Scopes 7 http://andyschwartz.wordpress.com/2009/07/31/whats-new-in-jsf-2

What s New in JSF 2? View Declaration Language and Facelets 2* Composite Components System Events Enhanced Navigation** GET Support** Bean Validation** Proper Error Handling* Project Stages First-class JavaScript and Ajax Support* Component Behaviors* Resource Handling Delta State Saving Tree Visiting Annotation-based Configuration JSR-299** Additional Scopes 8 http://andyschwartz.wordpress.com/2009/07/31/whats-new-in-jsf-2

Your kind of component /resources/property/display.xhtml <ui:composition> <comp:interface> <comp:attribute name="label" required="true"/> <comp:attribute name="value" required="false"/> </comp:interface> <comp:implementation> <div class="field" id="#{cc.clientid}> <span class="label">#{cc.attrs.label}:</span> <span class="value">#{cc.attrs.value}</span> </div> </comp:implementation> </ui:composition> 9

Your component in use /userdetail.xhtml Name of resources directory <f:view... xmlns:p= "http://java.sun.com/jsf/composite/components/property"... Base name of component template 10 <p:display id="username" label="username" value="#{user.username}"/> <p:display id="email" label="e-mail" value="#{user.email}"/> <p:display id="name" label="real name" value="#{user.name}"/>... </f:view>

Roadmap Background What s New? Red Hat s Contributions Community 11

Why contribute? JSF 1.2 Seam 12

GET Support and Bookmarkability Bookmarkable links and buttons (UIOutcomeTarget) <h:link> <h:button> Preemptive navigation Consult navigation rules at render time View-oriented functionality View metadata View parameters View processing events 13

View Parameters Evolution of Seam s page parameters Bind request parameters to model values Conversion Validation Propagate model values through bookmarkable URL 14

State in the URL (1) View parameters mapped in metadata facet <f:view> <f:metadata> <f:viewparam name="id" value="#{blog.entryid}"/> <f:event type="prerenderview" listener="#{blog.load}"/> </f:metadata> </f:view> View parameters appended to bookmarkable links <h:link value="link to entry"/> Outcome assumed to be current view ID 15

State in the URL (2) 16 View parameters appended to redirect URLs <navigation-rule> <from-view-id>/entry.xhtml</from-view-id> <navigation-case> <from-action>#{blog.postcomment}</from-action> <to-view-id>/entry.xhtml</to-view-id> <redirect include-view-params="true"/> </navigation-case> </navigation-rule> Or defined in navigation rule <h:link outcome="entry" <navigation-case> value="link to entry"/> <from-outcome>entry</from-outcome> <to-view-id>/entry.xhtml</to-view-id> <redirect> <view-param> <name>id</name><value>#{blog.entryid}</value> </view-param> </redirect> </navigation-case>

Implicit Navigation Return view ID from action method public String book() { return "/confirmation.xhtml"; } 17

Implicit Navigation Return root of view ID from action method public String book() { return "confirmation"; } 18

Implicit Navigation Redirect after action method (POST) public String book() { return "confirmation?faces-redirect=true"; } 19

Implicit Navigation Redirect with view parameters public String book() { return "confirmation?faces-redirect=true&includeviewparams=true"; } 20

Implicit Navigation in the View Declare target view ID in UICommand tag <h:commandbutton action="/createevent.xhtml" value="create"/> Simple redirect after POST <h:commandbutton action="createevent?faces-redirect=true" value="create"/> Declare target view ID in UIOutcomeTarget <h:link outcome="/agenda.xhtml" value="agenda"/> Current view ID used if outcome is absent 21

Conditional Navigation Navigation logic based on state <navigation-case> <from-action>#{bookingagent.checkdates}</from-action> <if>#{hotel.roomsavailable}</if> <to-view-id>/confirmbooking.xhtml</to-view-id> </navigation-case> 22

Partial Page Rendering Standardization of the Ajax4jsf <a4j:support> tag <f:ajax> Classified as a component behavior Formal JavaScript API jsf.ajax.request() More control over server-side processing PartialViewContext <f:ajax... render="@form"> 23

Partial Page Rendering Example <script type="text/javascript"> function controlspinner(status) { if (status.name == 'begin') { document.getelementbyid('spinner').style.display = 'inline'; } else if (status.name == 'complete') { document.getelementbyid('spinner').style.display = 'none'; } } </script>... <h:form id="search"> <h:inputtext id="query" value="#{searchcriteria.query}"> <f:ajax event="keyup" listener="#{hotelsearch.find}" render="hotels" onevent="controlspinner"/> </h:inputtext> </h:form>... <h:datatable id="hotels" value="#{hotels}" var="_hotel">... </h:datatable> 24

Partial Page Rendering Example <script type="text/javascript"> function controlspinner(status) { if (status.name == 'begin') { document.getelementbyid('spinner').style.display = 'inline'; } else if (status.name == 'complete') { document.getelementbyid('spinner').style.display = 'none'; } } </script>... <h:form id="search"> <h:inputtext id="query" value="#{searchcriteria.query}"> <f:ajax event="keyup" listener="#{hotelsearch.find}" render="hotels" onevent="controlspinner"/> </h:inputtext> </h:form>... <h:datatable id="hotels" value="#{hotels}" var="_hotel">... </h:datatable> 25

Partial Page Rendering Example <script type="text/javascript"> function controlspinner(status) { if (status.name == 'begin') { document.getelementbyid('spinner').style.display = 'inline'; } else if (status.name == 'complete') { document.getelementbyid('spinner').style.display = 'none'; } } </script>... <h:form id="search"> <h:inputtext id="query" value="#{searchcriteria.query}"> <f:ajax event="keyup" listener="#{hotelsearch.find}" render="hotels" onevent="controlspinner"/> </h:inputtext> </h:form>... <h:datatable id="hotels" value="#{hotels}" var="_hotel">... </h:datatable> 26

Bean Validation JSR-303: Bean Validation Red Hat led spec Centrally define validation constraints on model JSF integration: Extend validation to UI 27

Defining a Set of Constraints public class Booking {... @NotNull(message = "Credit card number is required") @Size(min = 16, max = 16, message = "Credit card number must 16 digits long") @Pattern(regexp = "^\\d*$", message = "Credit card number must be numeric") public String getcreditcardnumber() { return creditcardnumber; } } 28

Enforcing the Constraints in the UI 29 Put Bean Validation implementation on classpath <h:inputtext id="creditcard" value="#{booking.creditcardnumber}"/> Disable for single input <h:inputtext id="occupants" value="#{booking.numoccupants}"> <f:validatebean disabled="true"/> </h:inputtext> Disable per branch of component tree <f:validatebean disabled="true"> <h:inputtext id="occupants" value="#{booking.numoccupants}"/> </f:validatebean> Filter constraints by validation group Validation tag not required! <f:validatebean validationgroups="org.acme.reservedblock"> <h:inputtext id="groupcode" value="#{booking.groupcode}"/> </f:validatebean>

Bean Validation Integration Summary JSF automatically enforces field-level constraints I18N is inherited Handled by Bean Validation JSF passes constraint message as argument when resolving JSF validator message javax.faces.validator.beanvalidator.message={0} 30

Simple Select Items Create select items from any collection SelectItem should be an implementation detail public class CalendarBean { public List<Month> getmonths() { List<Month> months = new ArrayList<Month>(); months.add(new Month(0, "January"));... return months; } } <h:selectonemenu "#{booking.creditcardexpirymonth}"> <f:selectitems value="#{calendarbean.months}" var="_month" itemvalue="#{_month.index}" itemlabel="#{_month.name}" </h:selectonemenu> 31

Proper Exception Handling Handles unexpected exceptions No exceptions are swallowed! Ties into system events: ExceptionEvent Otherwise handled in web.xml <error-page> <exception-type> org.acme.authorizationexception </exception-type> <location>/denied.jsf</location> </error-page> Facelets debug page when project stage = development Custom debug page: javax.faces.error.xhtml 32

Native Resource Handler Serve JavaScript, images, CSS, etc. No bonus servlet required! Declarative and dynamic Resource structure Name Library Locale Version Packaging options /resources directory of web root 33 /META-INF/resources of classpath entry (JAR)

Request processing scenarios 34

Resolving a Resource localeprefix/libraryname/libraryversion/resourcename/resourceversion Highest version selected automatically Serve from /resources in web root <h:graphicimage name="visa.png"/> Path segments in gray are optional Serve from /META-INF/resources of creditcards.jar <h:graphicimage name="visa.png" library="creditcards"/> <h:graphicimage value="#{resources['creditcards:visa.png']}"/> 35

Resource Relocation Resources can target section of document Convenient for templating <h:head> <title>resource Relocation Example</title> </h:head> <h:body> <h:outputscript name="script.js" target="head"/> </h:body> 36

The book isn t closed Red Hat is still pushing for change in JSF 2.1 http://seamframework.org/documentation/jsf21 JSR-299 conversations need to be better recognized Bean Validation integration could go deeper JSF could still be simpler and easier Still many great ideas out there to be explored 37

Roadmap Background What s New? Red Hat s Contributions Community 38

Red Hat s Vision: An Open Specification Support from Oracle (Andy Schwartz) and Sun JSR-314 mailinglist open for reading http://archives.java.sun.com/jsr-314-open.html Login with free account required Only EG members can post JCP.org public forums http://wiki.jcp.org/boards/index.php?b=958 Relationship to mailinglist unclear JCP.org public wiki http://wiki.jcp.org/wiki/index.php?structure_id=6 39 Minimal activity so far

Share your vision 40

Summary 41 JSR-314 is a big step forward for JSF Key pain-points resolved JSP dumped for Facelets Simpler component development GET support (bookmarkable URLs) Ajax and JavaScript APIs Resource delivery Good integration with other specs JSR-299: Contexts and Dependency Injection JSR-303: Bean Validation Openness