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

Similar documents
Oracle Developer Day

Ajax and JSF: Natural Synergy

Advanced Topics in WebSphere Portal Development Graham Harper Application Architect IBM Software Services for Collaboration

"Charting the Course... WebSphere Portal 8 Development using Rational Application Developer 8.5. Course Summary

Oracle Developer Day

Improve and Expand JavaServer Faces Technology with JBoss Seam

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

Java EE 6: Develop Web Applications with JSF

Portlet Standard JSR 168 / JSR 286

Oracle Fusion Middleware 11g: Build Applications with ADF I

Advanced Software Engineering

Developing Applications for IBM WebSphere Portal 7.0

Introduction to Java Server Faces(JSF)

Oracle Fusion Middleware 11g: Build Applications with ADF I

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

Developing Applications with Java EE 6 on WebLogic Server 12c

WSRP Web Services for Remote Portlets

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

Best Practices for JSF Portlet Migration and Development

<Insert Picture Here>

JSR-286: Portlet Specification 2.0

Performance evaluation of J2EE

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

Tooling for Ajax-Based Development. Craig R. McClanahan Senior Staff Engineer Sun Microsystems, Inc.

Introduction Haim Michael. All Rights Reserved.

Essentials on Performant JavaServer Faces Apps. Client Versus Server Side

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

AJAX in Apache MyFaces A New Approach To Web Applications

Portlets and Ajax: Building More Dynamic Web Apps

IBM Rational Application Developer for WebSphere Software, Version 7.0

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

Financial. AngularJS. AngularJS.

DESIGN AND IMPLEMENTATION OF SAGE DISPLAY CONTROLLER PROJECT

An update on the latest strategies for building Ajax applications with JavaServer Faces

Financial. AngularJS. AngularJS. Download Full Version :

Standards and the Portals Project

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

Web Application Security

Using Adobe Flex in JSR-286 Portlets

Building JavaServer Faces Applications

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

Oracle Fusion Middleware 11g: Build Applications with ADF Accel

Oracle Developer Day

JSR-286: Portlet Specification 2.0

Beware of Serialized GUI Objects Bearing Data. David Byrne Rohini Sulatycki

JSF 2.0: Insight and Opinion

JavaEE Interview Prep

Building Web Applications With The Struts Framework

AJAX Programming Chris Seddon

WA2089 WebSphere Portal 8.0 Programming EVALUATION ONLY

Contents. 1. JSF overview. 2. JSF example

AJAX Programming Overview. Introduction. Overview

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

Table of Contents. Introduction... xxi

PGT T3CHNOLOGY SCOUTING. Google Webtoolkit. JSF done right?

Overview. Principal Product Manager Oracle JDeveloper & Oracle ADF

Part of this connection identifies how the response can / should be provided to the client code via the use of a callback routine.

IT Certification Exams Provider! Weofferfreeupdateserviceforoneyear! h ps://

Fast Track to Java EE

CITS3403 Agile Web Development Semester 1, 2018

Mastering JavaServer Faces

Developing Ajax Web Apps with GWT. Session I

The 60-Minute Guide to Development Tools for IBM Lotus Domino, IBM WebSphere Portal, and IBM Workplace Applications

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

Module 3 Web Component

Enriching Portal user experience using Dojo toolkit support in IBM Rational Application Developer v8 for IBM WebSphere Portal

AD105 Introduction to Application Development for the IBM Workplace Managed Client

PASS4TEST. IT Certification Guaranteed, The Easy Way! We offer free update service for one year

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

Delivering Rich Internet Applications with Ajax4jsf

CSC309: Introduction to Web Programming. Lecture 11

Services Interoperability With Java Technology and.net: Technologies for Web 2.0

Courses For Event Java Advanced Summer Training 2018

JSF. What is JSF (Java Server Faces)?

Web Programming. Lecture 11. University of Toronto

JavaScript Specialist v2.0 Exam 1D0-735

Liferay Faces. Reference Documentation ga2

Liferay Faces. Reference Documentation ga4

An Overview of. Eric Bollens ebollens AT ucla.edu Mobile Web Framework Architect UCLA Office of Information Technology

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

RIA Security - Broken By Design. Joonas Lehtinen IT Mill - CEO

Application Development in JAVA. Data Types, Variable, Comments & Operators. Part I: Core Java (J2SE) Getting Started

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

Chapter 10 Web-based Information Systems

REST AND AJAX. Introduction. Module 13

THIS IS ONLY SAMPLE RESUME - DO NOT COPY AND PASTE INTO YOUR RESUME. WE ARE NOT RESPONSIBLE Name: xxxxxx

JSF 2.0: Insight and Opinion

Enabling Web 2.0 User Experience for E-Business Suite. Padmaprabodh Ambale, Gustavo Jimenez Development Managers, Applications Technology Group

Java EE 7 is ready What to do next? Peter Doschkinow Senior Java Architect

Networking & The Web. HCID 520 User Interface Software & Technology

User Interaction: jquery

Portlets (JSR-168) Dave Landers. BEA Systems, Inc. Dave Landers Portlets (JSR-168)

CNIT 129S: Securing Web Applications. Ch 3: Web Application Technologies

IBM Realtests LOT-911 Exam Questions & Answers

AJAX and Persistence: Emerging Patterns and Pain Points

Java SE7 Fundamentals

COURSE 9 DESIGN PATTERNS

Web Presentation Patterns (controller) SWEN-343 From Fowler, Patterns of Enterprise Application Architecture

Beyond the Portlet API

SSC - Web applications and development Introduction and Java Servlet (I)

Transcription:

TS-6824 JavaServer Faces Technology, AJAX, and Portlets: It s Easy if You Know How! Brendan Murray Software Architect IBM http://www.ibm.com 2007 JavaOne SM Conference Session TS-6824

Goal Why am I here? Why are you here? Learn what it means to exploit AJAX and JavaServer Faces technology in a Portlet environment and to do it right first time. 2007 JavaOne SM Conference Session TS-6824 2

Agenda Introduction and background Characteristics of each technology JavaServer Faces technology and Portlet basics Mixing them all together The AJAX lifecycle Summary and questions 2007 JavaOne SM Conference Session TS-6824 3

Agenda Introduction and background Characteristics of each technology JavaServer Faces technology and Portlet basics Mixing them all together The AJAX lifecycle Summary and questions 2007 JavaOne SM Conference Session TS-6824 4

Introduction and Background JavaServer Faces technology, AJAX, and Portlets JavaServer Faces Technology Java Community Process SM (JCP SM ) services JSR 252 Version 1.2 leverages JavaServer Pages (JSP ) 2.1 Widely supported: Sun, IBM, BEA, Oracle, etc. Versions Sun s implementation Apache MyFaces (not at v1.2 yet) MVC-2 framework providing a server-based GUI JSR = Java Specification Request 2007 JavaOne SM Conference Session TS-6824 5

Introduction and Background JavaServer Faces technology, AJAX, and Portlets Portlets JSR 168 (v2.0 is JSR 286, due later this year) Broad support: Sun, IBM, BEA, Oracle, etc. Open Source version: Apache Pluto Provides an aggregation of web pages on the screen 2007 JavaOne SM Conference Session TS-6824 6

Introduction and Background JavaServer Faces technology, AJAX, and Portlets Asynchronous JavaScript and XML (AJAX) Originally called Remote Scripting Widespread use triggered by Google s applications Technique to create interactive web applications Zero-footprint rich Internet applications 2007 JavaOne SM Conference Session TS-6824 7

Agenda Introduction and background Characteristics of each technology JavaServer Faces technology and Portlet basics Mixing them all together The AJAX lifecycle Summary and questions 2007 JavaOne SM Conference Session TS-6824 8

Portlet Application User submits a request from a single portlet The portlet lifecycle is executed Action Render The portlet is updated The entire portal page is sent to the browser 2007 JavaOne SM Conference Session TS-6824 9

Portlet Lifecycle Portlet Action Request Init Process Action Portlet Render Request Init Render Destroy Portlet Response 2007 JavaOne SM Conference Session TS-6824 10

Portlet Issues Portlets communicate via the server No knowledge of client-side behaviors Client-side page contains a number of portlets Namespace-encoding prevents dynamic naming and dynamic URL manipulation 2007 JavaOne SM Conference Session TS-6824 11

Servlet JavaServer Faces Application User submits a request Lifecycle triggered Well-defined with six phases Servlet responds, rendering a single page created with the JavaServer Pages technology (JSP page) 2007 JavaOne SM Conference Session TS-6824 12

JavaServer Faces Technology Lifecycle Request Restore View Apply Request Values Process Validations Response Render Response Invoke Application Update Model Values 2007 JavaOne SM Conference Session TS-6824 13

JavaServer Faces Technology Issues No direct knowledge of client-side behaviors Components may render JavaScript technology, etc. Server-side GUI Server-side navigation 2007 JavaOne SM Conference Session TS-6824 14

AJAX Application User triggers a browser action Submit occurs programmatically Returned data processed by JavaScript technology Page updated directly on the client 2007 JavaOne SM Conference Session TS-6824 15

AJAX Issues No direct knowledge of server-side behaviors Assumes the entire application is in the client Can break synchronization of client and server 2007 JavaOne SM Conference Session TS-6824 16

Agenda Introduction and background Characteristics of each technology JavaServer Faces technology and Portlet basics Mixing them all together The AJAX lifecycle Summary and questions 2007 JavaOne SM Conference Session TS-6824 17

Portlet Basics: Java Technology URL encoding ExternalContext context = FacesContext. getcurrentinstance().getexternalcontext() ; String encurl = context.encodeactionurl(url); String encurl = context.encoderesourceurl(url); Name encoding String encname = context.encodenamespace( foo ); 2007 JavaOne SM Conference Session TS-6824 18

Portlet Basics: Java DHTML URLs Use renderresponse.encodeurl() href='<%= renderresponse.encodeurl( renderrequest.getcontextpath() + "/foo/bar.jsp") %> HTML Apply the portlet namespacing tag on IDs <tag name= <portlet:namespace />mytag > 2007 JavaOne SM Conference Session TS-6824 19

Basics: DHTML JavaScript technology function names Again, apply the portlet namespacing tag function <portlet:namespace />foo() { } JavaScript technology events Use EL to retrieve the namespace information <input type= button onclick= #{facescontext.externalcontext.response.namespace} foo() 2007 JavaOne SM Conference Session TS-6824 20

Portlets and JavaServer Faces Technology Originally based on FacesGenericPortlet class Mapped the two portlet phases to JavaServer Faces technology six phases Saved parameters in session for render phase Requires session JSR 301: Portlet Bridge Specification for JavaServer Faces technology Works transparently Does not assume presence of session Currently multiple versions IBM, Apache, and Sun 2007 JavaOne SM Conference Session TS-6824 21

Lifecycle Mapping: Action Phase Request Restore View Apply Request Values Process Validations Response Render Response Invoke Application Update Model Values 2007 JavaOne SM Conference Session TS-6824 22

Lifecycle Mapping: Render Phase Request Reconstitute Component Tree Apply Request Values Process Validations Response Render Response Invoke Application Update Model Values 2007 JavaOne SM Conference Session TS-6824 23

AJAX Sequence of Events Trigger a request on the browser portlet page Call updating function on server JavaServer Faces technology Lifecycle Data servlet Use the response to update the UI Markup returned Update the DOM directly Data returned Convert to DHTML Transform data to required format/markup Insert updated mark-up into page Use data directly Insert or replace data in DOM 2007 JavaOne SM Conference Session TS-6824 24

Agenda Introduction and background Characteristics of each technology JavaServer Faces technology and Portlet basics Mixing them all together The AJAX lifecycle Summary and questions 2007 JavaOne SM Conference Session TS-6824 25

Adding AJAX to the Mix Request processed by special servlet Return data Pure data stream with no mark-up Return mark-up Pre-build page content Request-response cycle independent of lifecycle Stateless servlet 2007 JavaOne SM Conference Session TS-6824 26

Adding AJAX to the Mix Using JavaServer Faces technology Full JavaServer Faces technology lifecycle Eliminate most of the page s mark-up Pre-formatted mark-up returned to page Partial JavaServer Faces technology lifecycle Interrupted by phase listener Pre-formatted mark-up returned to page 2007 JavaOne SM Conference Session TS-6824 27

AJAX: Data Servlet Generate pure data No need to process data as mark-up Data needs to be formatted for consumption XML, JSON Respond Data is processed at the client 2007 JavaOne SM Conference Session TS-6824 28

AJAX: JavaServer Faces Technology Lifecycle Generate page update via lifecycle Run full lifecycle Interrupt lifecycle by special phase listeners Filter out unnecessary information Only render required components Remove all other portlets mark-up Remove themes/skins mark-up Respond Send updated minimal mark-up 2007 JavaOne SM Conference Session TS-6824 29

Agenda Introduction and background Characteristics of each technology JavaServer Faces technology and Portlet basics Mixing them all together The AJAX lifecycle Summary and questions 2007 JavaOne SM Conference Session TS-6824 30

AJAX Using Full JavaServer Faces Technology Lifecycle We need to manage the rendering Only part of the page needs to be updated We don t want any Portal extras No theme information No skins No extra portlet mark-up We need to flag that it s an AJAX request Send a special indicator with the request Something must interpret this indicator 2007 JavaOne SM Conference Session TS-6824 31

Required Artefacts AJAXFacesContext AJAXFacesContextFactory AJAXExternalContext AJAXRenderkit AJAXRenderkitFactory AJAXRendererWrapper Helper classes Utility methods Minimal ResponseWriter 2007 JavaOne SM Conference Session TS-6824 32

AJAXFacesContext Factory Instantiates new AJAXFacesContext Saves original FacesContext object AJAXFacesContext Sets special minimal ResponseWriter AJAXExternalContext Manages ResponseWriters 2007 JavaOne SM Conference Session TS-6824 33

AJAXRenderKit Factory Wrappers all extant RenderKits to be AJAX-aware Renderkit Override getrenderer to wrapper renderers AJAXRendererWrapper Manages encodebegin and encodeend 2007 JavaOne SM Conference Session TS-6824 34

Identifying an AJAX Request Use hidden fields on page <input type= hidden name= MyAJAX id= MyAJAX value= > document.getelementbyid( MyAJAX ).value= OK ; Utility method to identify AJAX request public static boolean isajaxrequest(facescontext ctx) { String ajax = ctx.getexternalcontext().getrequestparametermap().get( MyAJAX ); return (null!= ajax && OK.equals(ajax)) } 2007 JavaOne SM Conference Session TS-6824 35

Identify What to Update Use hidden fields on page <input type= hidden name= MyAJAXId id= MyAJAXId value= > <h:panelgrid id= foo > document.getelementbyid( MyAJAXId ).value= foo ; Utility method to identify AJAX request public static String getajaxcomponent(facescontext ctx) { return ctx.getexternalcontext().getrequestparametermap().get( MyAJAXId ); } 2007 JavaOne SM Conference Session TS-6824 36

Client Side JavaScript technology Use XmlHttpRequest to call back to server Use DOM manipulations to update page 2007 JavaOne SM Conference Session TS-6824 37

DEMO JavaServer Faces Technology, Portlets, and AJAX 2007 JavaOne SM Conference Session TS-6824 38

Demo Contents Show implementation of code Create an application that leverages this code 2007 JavaOne SM Conference Session TS-6824 39

Agenda Introduction and background Characteristics of each technology JavaServer Faces technology and Portlet basics Mixing them all together The AJAX lifecycle Summary and questions 2007 JavaOne SM Conference Session TS-6824 40

Summary JavaServer Faces technology, Portlets, and AJAX work well together Creating a generic solution is not too difficult to implement The results look cool! 2007 JavaOne SM Conference Session TS-6824 41

For More Information Other sessions TS-9782: Ajax and JavaServer Faces Technology Tooling in Eclipse TS-9511: Ajax with POJC BOF-4664 Dynamic portals JSF Central: http://www.jsfcentral.com Books Pro JSF and Ajax: Building Rich Internet Components Jonas Jacobi and John Fallows JavaServer Faces: The Complete Reference Ed Burns, Chris Schalk, James Holmes 2007 JavaOne SM Conference Session TS-6824 42

Q&A 2007 JavaOne SM Conference Session TS-6824 43

TS-6824 JavaServer Faces Technology, AJAX, and Portlets: It s Easy if You Know How! Brendan Murray Software Architect IBM http://www.ibm.com 2007 JavaOne SM Conference Session TS-6824