1
What s New in Portlet 3.0 and JSF 2.2 Ed Burns @edburns Software Stylist, Oracle Corporation Presenting with
The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle s products remains at the sole discretion of Oracle. 3
Speaker Qualifications Involved with JSF since 2002 Spec lead since 2003 Most fun part of the job: cleanly integrating other people s great ideas into JSF (and hopefully improving on them in the process) Not an expert at applying JSF in practice Author of four books for McGraw-Hill 4
My Plan for Your Time Investment Portlet Technology Portlet Bridges The Standard JSF Portlet Bridges for Portlet 2.0 Some Examples CDI Portlet Bridges for Portlet 2.0 The Lifecycle Inter-Portlet Communication Portlet 3.0 Features CDI Scopes and the Portlet Lifecycle Sharing Resources between Portlets Simplified Parameter Handling Support for JSR-356 WebSocket JSF 2.2 Portlets Today CDI Integration HTML5 Friendly Markup Faces Flows Resource Library Contracts Stateless Views Ajax Push IPC 5 Copyright 2013 Liferay
Portlet Standard The Portlet Specification is a JCP standard that defines requirements for portlet containers and behavior of portlet applications JSR 168 Portlet 1.0 JSR 286 Portlet 2.0 JSR 362 Portlet 3.0 6 Copyright 2013 Liferay
Portlet Examples 7 Copyright 2013 Liferay
Servlet Lifecycle Single phase associated with HTTP GET/POST/PUT/DELETE operations: 8 Copyright 2013 Liferay
Portlet Lifecycle Multiple phases associated with HTTP GET/POST operations: 9 Copyright 2013 Liferay
Portlet Lifecycle 10 Copyright 2013 Liferay
Inter-Portlet Communication Inter-Portlet Communication (IPC) is a way of sharing data between two or more portlets Standard Mechanisms: Events IPC Public Render Parameters IPC demo 11 Copyright 2013 Liferay
Portlet 3.0 Features CDI Scopes and the Portlet Lifecycle Client-Side API Sharing resources between portlets Simplify API usage for handling parameters Support for JSR 356: Java API for WebSocket Improve support for mobile devices 12 Copyright 2013 Liferay
JSR-362 Expert Group Convened in March 2013 http://www.jcp.org/en/jsr/detail?id=362 Project Page (with Mailing List Signup) https://java.net/projects/portletspec3 Weekly teleconference meeting minutes: https://java.net/projects/portletspec3/pages/meetingminutes Portlet 3.0 API JavaDocs at GitHub: https://github.com/msnicklous/portletspec3 13 Copyright 2013 Liferay
Portlet 3.0 CDI Scopes EG is considering adding two CDI Scopes: @PortletLifecycleScoped For HTTP GET, exists for the duration of the RENDER_PHASE or RESOURCE_PHASE of the portlet lifecycle For HTTP POST, begins in the ACTION_PHASE and continues through to the RENDER_PHASE @PortletRedisplayScoped ACTION_PHASE to ACTION_PHASE Requirements first defined in JSR 329 PortletBridge Spec, known as the ìbridge Request Scopeî 14 Copyright 2013 Liferay
Portlet 3.0 Client Side API The JSR 362 EG will be considering: Client-side JavaScript API for portlets (portlet.js) Client-side mechanism for handling partial-page update (Similar in concept to JSF partial-response updates) Ability for the RESOURCE_PHASE to send IPC events or share public render parameters 15
Portlet 3.0 Additional Topics Sharing resources between portlets Simplify API usage for handling parameters Support for JSR 356: Java API for WebSocket Improve support for mobile devices 16 Copyright 2013 Liferay
Portlet Bridges JSF Portlet Bridges for Portlet 2.0 CDI Portlet Bridges for Portlet 2.0 17 Copyright 2013 Liferay
JSF Portlet Bridges for Portlet 2.0 Liferay Faces Bridge JBoss Portlet Bridge Apache MyFaces Portlet Bridge JSR 329 Reference Implementation 18 Copyright 2013 Liferay
CDI Portlet Bridges for Portlet 2.0 Liferay CDI Portlet Bridge <dependency> <groupid>com.liferay.cdi</groupid> <artifactid>cdi-portlet-bridge-shared</artifactid> <version>6.2.0.1</version> </dependency> JBoss CDI Portlet Integration <dependency> <groupid>org.gatein</groupid> <artifactid>cdi-portlet-integration</artifactid> <version>1.0.2.final</version> </dependency>" 19 Copyright 2013 Liferay
JSF 2.2 Portlets Today CDI Integration HTML5 Friendly Markup Support Faces Flows Resource Library Contracts Stateless Views Component Suites Ajax Push IPC 20 Copyright 2013 Liferay
JSF 2.2 CDI Integration New @ViewScoped annotation javax.faces.view.viewscoped instead of javax.faces.bean.viewscoped" New @FlowScoped annotation Like CDI @ConversationScoped with automatic begin and end 21
JSF 2.2 HTML5 Friendly Markup This is a JSF page <!DOCTYPE html>" <html xmlns="http://www.w3.org/1999/xhtml"" xmlns:myns="http://xmlns.jcp.org/jsf >" <form myns:id="form">" <input name="textfield" type="text" myns:value="#{bean.text1}" />" <input type="submit" myns:id="submitbutton" value="submit" /> " <p>submitted text: #{bean.text1}.</p>" </form>" </html>" " 22
JSF 2.2 HTML5 Friendly Markup Let s get back to basics JSF Views are written in a View Declaration Language (VDL). The standard Facelet VDL is an XML application with two kinds of elements HTML Markup JSF Components HTML Markup is passed through straight to the browser JSF Components take some action on the server, during the lifecycle 23
JSF 2.2 HTML5 Friendly Markup Let the elegance of HTML shine through Before JSF 2.2 JSF tags hide complexity of underlying HTML+script+css+images JSF Renderer : encode: markup to browser decode: name=value from browser <html> <my:colorpicker value= #{colorbean.color2} /> <my:calendar value= #{calendarbean.date1} /> </html> Context: Missing feature in browser? Write a JSF component. 24
JSF 2.2 HTML5 Friendly Markup Let the elegance of HTML shine through With JSF 2.2 Pure HTML+script+css+images in the JSF page JSF Renderer handles decode from browser Leverage the strength of the JSF lifecycle Leverage the expressiveness of HTML5 <html> <input type= color jsf:value= #{colorbean.color2} /> <input type= date jsf:value= #{calendarbean.date1} /> </html> Context: New feature in browser? Use pass through elements 25
Code Sample: TagDecorator Extension Came to JSF with Facelets 26
JSF 2.2 Faces Flows Standardized mechanism for connecting related JSF views Flows can be made reusable by packaging in a JAR Lessons learned from ADF Task Flow, Spring Web Flow, and Apache MyFaces CODI and standardizes 27
JSF 2.2 Resource Library Contracts Provides the ability for Facelet templates to be packaged in a JAR Including the JAR in a project makes it possible to apply the template in a reusable manner to an entire application 28
Resource Library Contracts Facelets Review The Facelets Gazette _template.html Site Navigation <ui:define name="headline"> Today's News </ui:define> Events Docs Forums <ui:define name="story"> Facelets is now a part of JSF 2.0... </ui:define> template client greeting.html About Contact Site Map 29
Resource Library Contracts Facelets Review The Facelets Gazette Template File name _template.html Site Navigation Insertion points Events Docs Forums About Contact Site Map Resources css classes, scripts, images 30
Resource Library Contracts A Contract is Born contracta Declared Templates Declared Resources 31
Resource Library Contracts Loading Conventions <web-app-root>/contracts contracta Declared contractb Templates Declared Declared contractc Resources Templates Declared Declared Resources Templates Declared Resources 32
Resource Library Contracts Loading Conventions <web-app-root>/contracts contracta Declared contractb Templates Declared Declared contractc Resources Templates Declared Declared Resources Templates Declared Resources JAR files in WEB-INF/lib contractd Declared contracte Templates Declared Declared contractf Resources Templates Declared Declared Resources Templates Declared Resources 33
Resource Library Contracts Loading Conventions <web-app-root>/contracts JAR files in WEB-INF/lib contracta Declared contractb Templates Declared Declared contractc Resources Templates Declared Declared Resources Templates Declared Resources contractd Set of available contracts Declared contracte Templates Declared Declared contractf Resources Templates Declared Declared Resources Templates Declared Resources 34
Resource Library Contracts Loading Conventions <web-app-root>/contracts JAR files in WEB-INF/lib contracta Declared contractb Templates Declared Declared contractc Resources Templates Declared Declared Resources Templates Declared Resources contractd Set of available contracts Declared contracte Templates Declared Declared contractf Resources Templates Declared Declared Resources Templates Declared Resources Facelet 1 Facelet 2 Facelet 3 35
Resource Library Contracts Loading Configuration <web-app-root>/contracts JAR files in WEB-INF/lib contracta Declared contractb Templates Declared Declared contractc Resources Templates Declared Declared Resources Templates Declared Resources contractd Set of available contracts Declared contracte Templates Declared Declared contractf Resources Templates Declared Declared Resources Templates Declared Resources faces-config.xml Facelet 1 Facelet 2 Facelet 3 36
Resource Library Contracts Loading Configuration <web-app-root>/contracts JAR files in WEB-INF/lib contracta contractb Declared Templates Declared contractc Templates Declared Resources Declared Declared Resources Templates Declared Resources contractd Set of available contracts contracte Declared Templates Declared contractf Templates Declared Resources Declared Declared Resources Templates Declared Resources faces-config.xml Facelet 1 <f:view contracts="contracta">... Facelet 2 Facelet 3 37
JSF 2.2 Stateless Views Informs the JSF StateManager that state is not to be applied to the view Consequence: Managed beans annotated with @ViewScoped essentially become like @RequestScoped <f:view transient= true > </f:view> 38
JSF 2.2 Component Suites Liferay Faces Alloy 4.x ICEfaces 3.3 PrimeFaces 4.0 RichFaces 5.0 (future) 39 Copyright 2013 Liferay
Ajax Push IPC Ajax Push IPC can be accomplished today using: ICEPush and ICEfaces PrimePush and PrimeFaces 40
Thank You Liferay is a registered trademark of Liferay, Inc. ICEfaces and ICEpush are trademarks of ICEsoft Technologies, Inc. RichFaces and JBoss Portlet Bridge are trademarks of Red Hat Inc. Oracle, Java, Java EE, and JavaServer are trademarks or registered trademarks of Oracle Corporation in the United States and in other countries Images of the Duke mascot are licensed under the new BSD 2-Clause License All other trademarks mentioned herein are the property of their respective owners 41
42
The preceding was intended to outline our general product direction. It was intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle s products remains at the sole discretion of Oracle. 43