javaone - 10 tips for java ee 7 with primefaces
DESCRIPTION
This presentation takes you on a JSF tour with the help of Java EE 7, together with PrimeFaces and the NetBeans IDE. The tour begins with an introduction of PrimeFaces and its features, such as UI components and themes. Focusing on Java EE 7, it examines HTML5-friendly templates, resource libraries contracts, Faces Flow, EL operators, and lambda magic. Throughout, you will be shown how to apply the principles and concepts learned, via working examples in the NetBeans IDE. The presentation is brought to you “from the horse's mouth”—that is, by PrimeFaces and NetBeans IDE engineers.TRANSCRIPT
![Page 1: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/1.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.1
![Page 2: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/2.jpg)
10 Tips for Java EE 7 with PrimeFacesMert Çalışkan &Martin FousekSoftware Architect Software Developer
at T2 Yazılım Ltd.at Oracle, NetBeans
![Page 3: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/3.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.3
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.
![Page 4: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/4.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.4
Agenda
Introduction– Java EE 7 & JavaServer Faces 2.2, PrimeFaces, NetBeans IDE
Tour through 10 features of the JSF and PF – Feature overview
– Samples in action
![Page 5: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/5.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.5
Java EE 7 – 14 JSRs and 9 MRs, themes:– HTML5
– Developer productivity
– Enterprise demands
JavaServer Faces 2.2 big ticket features:– HTML(5) Friendly Markup
– Faces Flow
– Resource Library Contract
Java EE 7 & JavaServer Faces 2.2
![Page 6: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/6.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.6
Open Source Component Library for JSF 2.xJSF 2.2 is supported with PF
version 4.x
Very Lightweight w/ Zero Configuration Plenty of examples in Showcase, extensive
theming, provides mobile components Well documented, user guides, books & etc. Large and active community
PrimeFaces
![Page 7: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/7.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.7
Open source IDE Support for Java, PHP, C/C++, Groovy Latest features
– Java SE 7, Java EE 7 and JavaFX
– HTML(5) client side development,CSS preprocessors, JavaSciprt frameworks
– Cordova, FindBugs, VCS improvements
– PHP 5.4 and the newest PHP frameworks
NetBeans IDE
![Page 8: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/8.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.8
Sample codes to demonstrate the tips Mavenized projects from Java EE 7 archetype Repository:
github.com/marfous/j1demo-pf
Sample Codes
![Page 9: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/9.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.9
HTML(5) Friendly Markup
![Page 10: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/10.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.10
HTML(5) Friendly Markup
New namespaces– passthrough elements: http://xmlns.jcp.org/jsf (TagDecorator)
– passthrough attributes: http://xmlns.jcp.org/jsf/passthrough (RenderKit)
Advantages– Getting control over rendered Facelets
– JSF components / JavaScript components / arbitrary mixing
– Write and style pure HTML with benefits of JSF
![Page 11: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/11.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.11
Form with usage of HTML friendly markup: validation by Bean Validation API with localized messages, custom Bean Validation annotation, passthrough attributes and elements, usage of jQuery plugin at JSF component.
01-HtmlFriendlyMarkuphttps://github.com/marfous/j1demo-pf
HTML(5) Friendly Markup
![Page 12: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/12.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.12
Resource Libraries Contracts
![Page 13: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/13.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.13
Resource Libraries Contracts
Theme definitions across one or more web applications Libraries consisting of templates, insertion points, resources Can be bundled directly into Web Application or within .jar library How to choose the used one:
– there is only one option
– static or dynamic view definition
– URL based definition within faces-config
Multi-templating
![Page 14: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/14.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.14
Simple Resource Libraries Contracts usage, switching RLCs dynamically using Expression Language and ManagedBean.
02-ResourceLibrariesContractshttps://github.com/marfous/j1demo-pf
Resource Libraries Contracts
![Page 15: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/15.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.15
Expression Language 3.0
![Page 16: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/16.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.16
Expression Language 3.0
Communication between presentation layer and application logic Deferred or immediate evaluation of expressions Sets and gets data, invokes methods Features
– Standalone ELProcessor
– Concatenation, semicolon and assignments operators
– Static collections
– Collection Operations (aligned with Java SE 8)
– Lambda Expressions (aligned with Java SE 8)
![Page 17: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/17.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.17
Examples of Expression Language 3.0 features: standalone EL Processor, operators, static fields, collections, lambdas and collection operations.
03-ExpressionLanguage3https://github.com/marfous/j1demo-pf
Expression Language 3.0
![Page 18: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/18.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.18
Prime Time with PrimeFaces Components
![Page 19: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/19.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.19
Prime Time with PrimeFaces Components
With 100+ Rich Set of Components Built-in Ajax based on standard JSF 2.0 Ajax APIs Client APIs based on Enterprise theming w/ Theme Roller
With 4.0 – Sentinel We’re introducing cool stuff like,– Client Side Validation
– Dialog Framework
– Tree Drag & Drop
– Deferred Loading and many more…
![Page 20: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/20.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.20
Examples on advanced UI components:DataTable, Gmap, AutoComplete, Client Side Validation, Tree Drag and Drop, The Dialog Framework and others.
10-PrimeFacesComponentshttps://github.com/marfous/j1demo-pf
Prime Time with PrimeFaces Components
![Page 21: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/21.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.21
In the Jungle of PrimeFaces Themes
![Page 22: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/22.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.22
In the Jungle of PrimeFaces Themes
Powered w/ jQueryUI and ThemeRoller CSS FrameworkSkinning and Structural CSS architecture
ThemeRoller provides visual editor to create new themes ~40 themes available by only adding JAR dependency Advanced themes are also available
– Twitter Bootstrap Theme
– Metro UI Theme ($$)
Configuration is done by <context-param> in web.xml
![Page 23: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/23.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.23
Theme variations on UI Components
Configuration of theme infrastructure
04-PrimeFacesThemeshttps://github.com/marfous/j1demo-pf
In the Jungle of PrimeFaces Themes
![Page 24: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/24.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.24
PrimePush, PrimeUI and PrimeMobile
![Page 25: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/25.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.25
PrimePush, PrimeUI and PrimeMobile
PrimePush brings first class support with Atmosphere Framework– WebSockets, long polling, streaming, jsonp
PrimeUI is spin-off from the JSF suite, provides rich javascript widgets– autoComplete, dataTable and many others (~35 components)
PrimeMobile offers UI components for mobile devices, supports for:– powered by jQuery
![Page 26: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/26.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.26
PrimePush Checkin Demo w/ PrimeMobile in Action
PrimeUI integrated with REST Services
05-PrimePushUiMobilehttps://github.com/marfous/j1demo-pf
PrimePush, PrimeUI and PrimeMobile
![Page 27: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/27.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.27
JSF scaffolding with PrimeFaces
![Page 28: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/28.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.28
JSF scaffolding with PrimeFaces
Generation of CRUD skeleton from the database– NetBeans IDE: JSPs or vanilla Facelets
– nbpfcrudgen plugin: Facelets with PrimeFaces
Last feature – NetBeans 7.3.1 generates CDI artifacts Procedure
– Generate entity classes from database
– Generate JSF pages from entities
![Page 29: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/29.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.29
CRUD application generation using standard JavaServer Faces templates, generation of PrimeFaces templates.
06-JsfPrimeFacesScaffoldinghttps://github.com/marfous/j1demo-pf
JSF scaffolding with PrimeFaces
![Page 30: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/30.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.30
Faces Flows
![Page 31: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/31.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.31
Faces Flows
Reusable collection of screens with defined entry and exit points Nodes like switchNode, finalizer, methodCall etc. Derived from proven technologies: Spring WebFlow, ADF Task Flow JSF bound with CDI - @FlowScoped Definition:
– Faces-config configuration file
– Java definition using FlowBuilder (@FlowDefinition)
![Page 32: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/32.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.32
Sample wizard using navigation elements of the Faces Flow, flow scope defined bean, Faces Flow component as a plugable library.
07-FacesFlow, 07-FacesFlowLibraryhttps://github.com/marfous/j1demo-pf
Faces Flows
![Page 33: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/33.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.33
Annotation based component registration
![Page 34: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/34.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.34
Annotation based component registration
Improved FacesComponent interface Eliminates needs for the TLD file CDI capable component
@FacesComponent(createTag = true,
namespace = ... , // implicitly: http://xmlns.jcp.org/jsf/component
tagName = ...) // implicitly: lowercased class name
![Page 35: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/35.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.35
Usage of the tag defined by @FacesComponent without any tag library, CDI binding in the component, Java SE project as a custom tag library.
08-FacesComponent, 08-FacesComponentLibraryhttps://github.com/marfous/j1demo-pf
Annotation based component registration
![Page 36: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/36.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.36
File Upload
![Page 37: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/37.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.37
File Upload
Servlet 3.0 multipart architecture Standard component with/without AJAX requests For lower JSF versions already available as PrimeFaces component
Prerequisites– Enctype multipart/form-data of the form
– Servlet 3.0
![Page 38: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/38.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.38
File Upload of the standard JSF 2.2 and PrimeFaces library in action, with validation of type and size limit.
09-FileUploadhttps://github.com/marfous/j1demo-pf
File Upload
![Page 39: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/39.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.39
PrimeFaces Cookbook Over 90 practical recipes to learn PrimeFaces
written by: Oleg Varaksin & Yours Truly
Author discount 40% with code: -
![Page 40: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/40.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.40
Useful Links
http://docs.oracle.com/javaee/7/tutorial/doc/home.htm
http://www.primefaces.org/showcase
http://blog.primefaces.org
https://netbeans.org/kb/trails/java-ee.html
http://sourceforge.net/projects/nbpfcrudgen
![Page 41: JavaOne - 10 Tips for Java EE 7 with PrimeFaces](https://reader033.vdocument.in/reader033/viewer/2022042714/554f6cddb4c9058a148b500a/html5/thumbnails/41.jpg)
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.41
Graphic Section Divider