1k likes | 1.56k Views
JavaFX Versus HTML5. Ryan Cuprak, Dassault Systemès David Grieve, Oracle. Agenda. Demo Application Technical Comparison JavaFX in Perspective HTML5 in Perspective Analysis Integration Summary. Both designed and engineered using Dassault Systèmes CATIA software!.
E N D
JavaFX Versus HTML5 Ryan Cuprak, DassaultSystemès David Grieve, Oracle
Agenda Demo Application Technical Comparison JavaFX in Perspective HTML5 in Perspective Analysis Integration Summary Both designed and engineered using DassaultSystèmes CATIA software! https://github.com/rcuprak/n34sailor
Demo Application JavaFX replaces Swing Swing was a 1990s technology – different era Swing has significant shortcomings: • No support for touch • Hard to customize appearance • JTable feature poor with complex code • No support for animation • No data binding support • No support for animations • Some customization require changes to L&F classes Why not Swing?
Demo Application HTML5 has arrived on the desktop HTML5 has arrived on mobile HTML5 apps are apps! • Logic written in JavaScript • UI HTML5/CSS3 HTML5 apps are gaining device support: • Compass/GPS/Accelerometers/BlueTooth Background
Demo Application Mobile – using HTML5 and Apache Cordova Apps not websites! • HTML5 enables app development • Excitement is around app development • Rich user experiences • Not talking about JSF + HTML5 What type of demo application?
Demo Application What type of demo application? Not this type of web app!
Demo Application Sailboat Racing Start/Finish
Demo Application Architecture Interface JavaFX JAX-RS WebSocket Apache Cordova EJB Application JPA Entities Entities JMS CDI JPA Infrastructure
Demo Application Committee boat sets the course and announces it via radio. Boats register via radio specifying their class. Start sequence for class: Warning horn is sounded Start horn is sounded (boats cross start line) Start sequence repeated for next class. Committee boat monitors progress and weather. Race course altered if wind dies or conditions deteriorate. Finish time for each boat is registered at the end of the race Final results are calculated. Sailboat Racing Overview
Mobile Overview Single Page Application (SPA) wrapped in Native application. Native application displays a WebView– embedded browser. Logic: JavaScript JavaScript platform extensions UI HTML5 markup SVG Canvas WebGL All assets are bundled with the application. Native HTML5 Apps Immersive App logic In JavaScript
Mobile Overview Native HTML5 vs. Web Apps HTTP Session JSF/JSP/Facelets
Demo Application UI Mockup
Demo Application JavaFX Vanilla JavaFX– designed using Scene Builder 2.0 JAX-RS 2.0 (Jersey) WebSockets (Tyrus) Java API for JSON Processing HTML5 Apache Cordova (Android/iOS/Windows/Tizen/BlackBerry) JQuery JQuery Mobile Knockout JS Technologies
Mobile Overview Mobile Frameworks Advice: Don’t reinvent the wheel! Also Angular can be used…
Mobile Overview Secha Architect • Forces good MVC practices • Development similar to that in xCode, Android Studio • Costs $400 for a license
Demo Application JavaFX No camera integration No GPS integration Connectivity information (network availability/type) HTML5 UI layout Background threading Browser support – IndexDB Material Differences
Technical Comparison HTML5 • UI constructed using HTML5 markup • Logic implemented using JavaScript • Tooling: NetBeans JavaFX • UI constructed using FXML • Logic implemented using Java • Tooling: NetBeans, Scene Builder 2 High Level Overview
Technical Comparison JavaFX: Architecture with Controllers fxml fxml fxml fxml fxml Login Map Weather Navigation Chat Main MainMenu Race fxml fxml fxml Register
Technical Comparison JavaFX: Controller Architecture
Technical Comparison JavaFX: UI Flow JoinRace.fxml invokes confirmAction(ActionEvent) RaceController sets the data on RaceController.
Technical Comparison HTML5: SPA Architecture index.html <html><body> <div id=“page”> <a href=“menu.html”> Menu </a> </div> </body></html> menu.html <html><body> <div id=“page”> <a href=“info.html”> Info </a> </div> </body></html> <a href=“info.html”> Info </a> info.html <html><body> <div id=“page”> Info </div> </body></html> Info
Technical Comparison HTML5: Page Flow account.html results.html index.html welcome.html login.html menu.html register.html joinRace.html tracking.html weather. info.html chat.html
Technical Comparison HTML5: UI Flow menu.html joinRace.html App.js Race.js - pageBeforeShow() - pageChange() - getRaces() - pageBeforeJoinRaces() - joinSelectedRace() menu.html - <a id="raceMenu" onclick="getRaces();">Join Race</a> app.js – pageChange() app.js – pageBeforeShow() -> Race.jsgetRaces() joinRace.html - <button type="button" id="Login" onclick="joinSelectedRace();" value="Login">Confirm</button>
Technical Comparison HTML5: UI Transitions Changing to another page: Processing a page before rendering:
Technical Comparison HTML5: Apache Cordova + JQuery Mobile Initialization App “states” are different.
Technical Comparison HTML5: Loading Data JQuery Mobile – varies by JavaScript library
Technical Comparison HTML5: Using Knockout Using Bindings
Technical Comparison Converting data to JSON becomes more complicated: HTML5: Knockout Complications
Technical Comparison JavaFX: Data Binding Bound using @FXML @FXML void userNameEntered(ActionEvent)
Technical Comparison JavaFX: Binding Conditionally enable the login button
Technical Comparison Busy Indicator
Technical Comparison JavaFX: Busy Indicator
Technical Comparison JavaFX: Busy Indicator
Technical Comparison HTML5: Busy Indicator – Animation Markup
Technical Comparison HTML5: Busy Indicator – Animation with CSS3
Technical Comparison HTML5: Tables JQuery plug: Data Tables http://www.datatables.net
Technical Comparison HTML5: Tables
Technical Comparison JavaFX: Tables
Technical Comparison JavaFX: Tables
Technical Comparison Server Communication Java EE 7 App Server Client REST Restful Web Service Request/Response Web Sockets Web Socket Endpoint Bidirectional
Technical Comparison JavaFX • Not part of Java 8. • Websocket: Project Tyrus https://tyrus.java.net/index.html • REST: Project Jersey https://jersey.java.net • JSON Processing https://jsonp.java.net HTML5 • REST – native support: • Xmlhttp – used to issue AJAX calls. • WebSocket – native support: • WebSocket – used to register callbacks and send data. Server Communication
Technical Comparison HTML5: WebSocket Support http://caniuse.com/#search=webso
Technical Comparison Java Objects! Java: REST Invocation Java API for JSON JAX-RS Client
Technical Comparison HTML5: REST Invocation
Technical Comparison HTML5: WebSocket Support
Technical Comparison JavaFX: WebSocket Support
Technical Comparison HTML5: Layout Challenges
Apache Cordova HTML5: Device Access