SlideShare a Scribd company logo
Using Java with
HTML5 and CSS3
(+ the whole HTML5 world:WebSockets, SVG, etc...)
Helder da Rocha
Independent Java & Web professional
Argo Navis Informatica Ltda. São Paulo, Brazil
helder@argonavis.com.br
Agenda
• A short introduction to some cool HTML5
features
• Some ideas about how to explore the
power of HTML5 in Java Web apps
Who am I?
h"p://www.youtube.com/watch?v=jHteVqfKhNo	
  
Java,	
  Web,	
  iOS	
  programmer,	
  consultant,	
  instructor	
  
Java	
  enthusiast	
  since	
  1995	
  
(also	
  actor,	
  musician	
  and	
  visual	
  arLst	
  :)	
  
From	
  Brazil
Java & HTML: old friends
• 1995: Applets running inside HotJava & Netscape
browsers
• Client-side Java
• First attempt at rich interactive interfaces
• Before applets there was no such thing as
animation and interactivity on the Web
• Scripting and Netscape extensions allowed
Java-HTML communication
Today
• Proprietary solutions like Flash became de
facto standards for interactive client-side apps
• Java became popular for server-side apps
• Many tasks that would fit better on the client-
side are still done on the server-side because
of inconsistent browser support
HTML5
• Still a versioned spec under W3C, but a versionless
dynamic spec under WHAT-WG (Web Hypertext
Application Technology Working Group)
• Has among its goals to simplify HTML code and
drastically reduce the need for scripting and plugins
• Deals not only with graphical aspects and structure, but
also with networking, multithreading, storage, etc. (which
are no longer part of the official spec)
HTML5
is not just HTML
• The “HTML5 solution” includes
• CSS, JavaScript, audio & video, vector graphics
• But also Web sockets, geolocation, offline
cache,Web workers, client-side database, local
storage, etc.
• More than just graphical technologies
JSF support?
• There is not yet any official support for
HTML5 from HTML-generating frameworks
such as JSF
• HTML5 support is expected for JSF 2.2
(Java EE 7)
• But any server-side Java apps can use data
sent by HTML5 client-side apps
Some cool graphical
features
• HTML5 Canvas
• WebGL
• CSS3 animations and transitions
• SVG
• Audio and video control
HTML5 Canvas
• API-based vector graphics
1. Place the <canvas> element somewhere (or create it
via scripting)

<canvas id=”mycanvas” width=”200″ height=”200″/>
2. Change its style if you wish

<style> canvas {border: solid black 1px} </style>
3. Get the 2D context

var acanvas = document.getElementById("mycanvas");

var ctx = acanvas.getContext("2d");
4. Use the API to paint your canvas

ctx.fillStyle = "rgb(255,0,0)”;

ctx.fillRect(50, 50, 100, 100);
WebGL: 3D animations
• Not really HTML5, but built on Canvas
Saving and retrieving
graphics
• Server-side applications can be used to save
the state of HTML5 graphics
• Serializing Canvas or SVG to the server
• Saving parameters that were changed by
the user
• Saved state may be recovered later and be
used to restore page
• Ex: collaborative images, signatures, etc.
Saving the state of the canvas
• You can use a Java server-side app to save
the state of a canvas drawn by the client
• Canvas can be converter to image via
API methods (toDataUrl())
Canvas
Servlet
CSS3 transforms
• 2D and 3D transforms on any element:
scale, translate, rotate, etc.
• Can be combined with animations and
transitions
• Sophisticated effects can be obtained with
no scripting at all
CSS3 animations
• Declarative transitions, 3D animations and
effects like shadows, reflections, etc.
• Reduces the need for scripting
#frente {
position:absolute; top: 0px; left: 0px;
-webkit-transform: translateZ(10px) scaleZ(1.2) scale(0.5);
-webkit-transform-style: preserve-3d;
}
#verso {
position:absolute; top: 0px; left: 0px;
-webkit-transform: translateZ(-10px) scaleZ(1.2) scale(0.5);
-webkit-transform-style: preserve-3d;
}
#cena {
-webkit-animation: flip 8s infinite linear;
-webkit-transform-style: preserve-3d;
}
@-webkit-keyframes flip {
from { -webkit-transform: rotateY(0deg);}
to {-webkit-transform: rotateY(-360deg);}
}
SVG - ScalableVector Graphics
• W3C XML standard initially based on Microsoft
VML and Adobe PostScript
• Initially supported by Adobe and Microsoft
• Can be embedded in HTML or linked via the
<img> element
<?xml	
  version="1.0"	
  encoding="UTF-­‐8"?>

<svg	
  xmlns="http://www.w3.org/2000/svg"	
  

	
  	
  	
  	
  	
  width="100%"	
  height="100%">

	
  	
  	
  	
  <circle	
  r="50"	
  cx="100"	
  cy="100"	
  fill="green"/>	
  

	
  	
  	
  	
  <circle	
  r="50"	
  cx="125"	
  cy="125"	
  fill="green"	
  

	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  fill-­‐
opacity="0.5"/>	
  

	
  	
  	
  	
  <circle	
  r="50"	
  cx="150"	
  cy="150"	
  fill="green"	
  

	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  fill-­‐
opacity="0.2"/>	
  

</svg>
Saving SVG
• It is not as easy as saving Canvas, since it
requires serializing by third-party client-side
XML processors which are browser-
dependent (need to save the DOM tree)
• But you can easily collect data from the client
side and generate SVG on the server side
• Frameworks like Apache Batik can also
convert SVG to images
SVG generation
• Since SVG is XML, it can be generated on
the server-side using XML authoring APIs,
• Can also be generated a a template by
vector software (like Illustrator) and later
modified (inserting DOM nodes, removing,
reordering, etc.)
Generating SVG through
XSLT and Java
SVG
template
XSLT
Java
component
javax.xml

APIs
SVG for
embedding
Parameters
PNG,

PDF
Servlet-generated SVG
Other features
• Web database
• Local storage
• Web workers
• Web sockets
• Geolocation
Web storage
• Safer local and session storage objects
• Two objects which accept any properties:
localStorage and sessionStorage
• Ex: localStorage.field = “Hi!”;
• localStorage is not shared among tabs
or windows.
• You can’t insert data into them directly
from the server (it has to be via scripting)
Client-side database
var db = openDatabase('mydb', '1.0', 

'hellodb', 2 * 1024 * 1024);
db.transaction(
function (tx) {


tx.executeSql(

'CREATE TABLE IF NOT EXISTS
mytable(id unique, name)');


tx.executeSql(

'INSERT INTO mytable(id, name) 

VALUES (1, ”Jack")');

}
);
• For applications which require a lot of
structured offline data (ex: animations)
Web workers
• Threading API for JavaScript
• Create thread code in a JS file, and attach it to a
Worker object
var worker = new Worker(“worker.js”);
• Attach a listener function
worker.onmessage = function(evt) {
alert(evt.data);
};
• Send an asynchronous message
worker.postMessage(“data”);
Geolocation
• Uses the navigator object to store
geolocation coordinates
position.coords.latitude & longitude
• Once collected, you can send them
anywhere
• Ex: if you send them to a Java server-side
application, they can be used to generate
an SVG map, for example.
Web Sockets
• A completely new protocol that uses HTTP
as a bootstrap
• Also has an IETF spec: RFC 6455
• Allows real-time bidirectional
communication (like Comet)
• Requires support from both the server-side
and the client-side
Protocol
• Starts with an HTTP handshake via headers
• After communication is established, data packets can be
exchanged
• Packet format is defined by the protocol spec
GET /mychat HTTP/1.1
Host: server.example.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
Sec-WebSocket-Protocol: chat
Sec-WebSocket-Version: 13
Origin: http://example.com
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
Sec-WebSocket-Protocol: chat
WebSocket API
• Interface
WebSocket(url, [protocols])
• Events
onopen
onerror
onclose
onmessage
• States
0 – CONNECTING 1 – OPEN

2 – CLOSING 3 - CLOSED
• Methods
send(String | blob | arraybuffer )
close()
Client	
  JavaScript	
  API
• How	
  to	
  use	
  it	
  (client-­‐side)
var	
  ws	
  =	
  new	
  WebSocket("ws://localhost:8080/myapp");	
  
ws.onopen	
  =	
  funcLon(event)	
  {	
  
	
   alert("Opened	
  connecLon!");	
   	
  
}	
  
ws.onmessage	
  =	
  funcLon(event)	
  {	
  
	
   alert("Message:	
  "	
  +	
  event.data);	
  
}	
  
ws.onclose	
  =	
  funcLon(event)	
  {	
  
	
   	
  	
  alert("Closed	
  connecLon!");	
   	
   	
   	
  
}	
  
ws.send("Hello	
  World!");
send()	
  method
Event	
  handlers
WebSocket	
  object
What about the server side?
• Still no standard. But there should be one
soon (JSR 356 + Java EE 7)
• You can write your own WebSocket server,
of course (study the protocol and handle it
with a java.net.ServerSocket or
javax.servlet implementation)
• You can use Glassfish+Grizzly, Jetty, JBoss,
or some other proprietary solution
Battleship
Client-side
var ws;
function initWS() {
ws = new WebSocket("ws://localhost:8080/../WSBattleship");
ws.onmessage = function(event) {
if (gameStarted) {
var msg = event.data.split(":");
if (msg[0] != playerId) {
hitOrMiss(msg[1], msg[2]);
}
}
alert(event.data);
}
}
function hitOrMiss(coords, event) {
if (event == 0) {
markMiss(coords);
} else {
markHit(coords);
}
}
function shoot(ship) {
if (gameStarted && !gameFinished) {
ws.send(playerId + ":" + shotPosition);
}
}
function addShip(ship) {
if (!gameStarted && totalShips < maxShips) {
ships[totalShips++] = ship.id;
ship.style.fill = "red";
}
if (totalShips == maxShips) {
ready = true;
ws.send(playerId); // ready signal!
}
}
WebSockets	
  app	
  using	
  Grizzly
• Write the component & socket
• Register the component using a servlet
public class MyServlet extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
WebSocketEngine.getEngine().register(new BattleShipComponent());
}
}
public class BattleShipComponent extends WebSocketApplication {
public WebSocket createSocket(WebSocketListener... listeners) {
return new BattleShipSocket(listeners);
}
public void onMessage(WebSocket socket, String data) {
String gameData = data.split(":");
...
}
} public class BattleShipSocket extends BaseServerWebSocket {
public BattleShipSocket(WebSocketListener... listeners) {
super(listeners);
}
}
WebSockets: battleship
WS Component
Web
Socket
Web
Socket
Servlet WebSocket Engine
1:a2
Text
Grizzly 1.9 + Glassfish 3.1.2
Summary
• Although there is no official support for HTML5 in Java
Web technologies such as JSF (expected for Java EE 7), Java
server-side apps can enhance client-side HTML5 apps
• Information collected by HTML5 can be used as parameters
for server-side processing, where many Java APIs can be used
• SVG can be easily generated on the server-side and embedded
into HTML pages
• Canvas (and SVG) can be serialized and stored on the server
• WebSocket applications require server-side support.
Currently there are several Java-based proprietary
solutions. JSR 356 aims to standardize this.
• Of course, browser support is still the main concern
Thank you
Helder da Rocha
Twitter @helderdarocha
www.argonavis.com.br

More Related Content

What's hot

Drupal Backbone.js in the Frontend
Drupal Backbone.js in the FrontendDrupal Backbone.js in the Frontend
Drupal Backbone.js in the Frontend
David Corbacho Román
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO DevsWO Community
 
Drupal 6 JavaScript and jQuery
Drupal 6 JavaScript and jQueryDrupal 6 JavaScript and jQuery
Drupal 6 JavaScript and jQuery
Matt Butcher
 
Svcc 2013-css3-and-mobile
Svcc 2013-css3-and-mobileSvcc 2013-css3-and-mobile
Svcc 2013-css3-and-mobile
Oswald Campesato
 
Backbone js
Backbone jsBackbone js
Backbone js
Rohan Chandane
 
Building production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stackBuilding production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stack
CellarTracker
 
RESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsRESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side Components
Sven Wolfermann
 
Pushing the Boundaries of Sencha and HTML5′s WebRTC
Pushing the Boundaries of Sencha and HTML5′s WebRTCPushing the Boundaries of Sencha and HTML5′s WebRTC
Pushing the Boundaries of Sencha and HTML5′s WebRTC
Rich Waters
 
Building an E-commerce website in MEAN stack
Building an E-commerce website in MEAN stackBuilding an E-commerce website in MEAN stack
Building an E-commerce website in MEAN stack
divyapisces
 
Write Powerful Javascript Modules To Make Your Apps DRY (Brian Leathem)
Write Powerful Javascript Modules To Make Your Apps DRY (Brian Leathem)Write Powerful Javascript Modules To Make Your Apps DRY (Brian Leathem)
Write Powerful Javascript Modules To Make Your Apps DRY (Brian Leathem)
Red Hat Developers
 
An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications
Rohan Chandane
 
Node.js, toy or power tool?
Node.js, toy or power tool?Node.js, toy or power tool?
Node.js, toy or power tool?Ovidiu Dimulescu
 
Writing & Using Web Services
Writing & Using Web ServicesWriting & Using Web Services
Writing & Using Web ServicesRajarshi Guha
 
Writing RESTful web services using Node.js
Writing RESTful web services using Node.jsWriting RESTful web services using Node.js
Writing RESTful web services using Node.js
FDConf
 
Алексей Швайка "Bundling: you are doing it wrong"
Алексей Швайка "Bundling: you are doing it wrong"Алексей Швайка "Bundling: you are doing it wrong"
Алексей Швайка "Bundling: you are doing it wrong"
Fwdays
 
Overview Of Lift Framework
Overview Of Lift FrameworkOverview Of Lift Framework
Overview Of Lift Framework
Xebia IT Architects
 
Overview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkOverview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web Framework
IndicThreads
 
Node js for enterprise
Node js for enterpriseNode js for enterprise
Node js for enterprise
ravisankar munusamy
 
Meanstack Introduction by Kishore Chandra
Meanstack Introduction by Kishore ChandraMeanstack Introduction by Kishore Chandra
Meanstack Introduction by Kishore Chandra
Kishore Chandra
 

What's hot (20)

Html5
Html5Html5
Html5
 
Drupal Backbone.js in the Frontend
Drupal Backbone.js in the FrontendDrupal Backbone.js in the Frontend
Drupal Backbone.js in the Frontend
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
 
Drupal 6 JavaScript and jQuery
Drupal 6 JavaScript and jQueryDrupal 6 JavaScript and jQuery
Drupal 6 JavaScript and jQuery
 
Svcc 2013-css3-and-mobile
Svcc 2013-css3-and-mobileSvcc 2013-css3-and-mobile
Svcc 2013-css3-and-mobile
 
Backbone js
Backbone jsBackbone js
Backbone js
 
Building production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stackBuilding production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stack
 
RESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side ComponentsRESS – Responsive Webdesign and Server Side Components
RESS – Responsive Webdesign and Server Side Components
 
Pushing the Boundaries of Sencha and HTML5′s WebRTC
Pushing the Boundaries of Sencha and HTML5′s WebRTCPushing the Boundaries of Sencha and HTML5′s WebRTC
Pushing the Boundaries of Sencha and HTML5′s WebRTC
 
Building an E-commerce website in MEAN stack
Building an E-commerce website in MEAN stackBuilding an E-commerce website in MEAN stack
Building an E-commerce website in MEAN stack
 
Write Powerful Javascript Modules To Make Your Apps DRY (Brian Leathem)
Write Powerful Javascript Modules To Make Your Apps DRY (Brian Leathem)Write Powerful Javascript Modules To Make Your Apps DRY (Brian Leathem)
Write Powerful Javascript Modules To Make Your Apps DRY (Brian Leathem)
 
An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications An Introduction To Testing In AngularJS Applications
An Introduction To Testing In AngularJS Applications
 
Node.js, toy or power tool?
Node.js, toy or power tool?Node.js, toy or power tool?
Node.js, toy or power tool?
 
Writing & Using Web Services
Writing & Using Web ServicesWriting & Using Web Services
Writing & Using Web Services
 
Writing RESTful web services using Node.js
Writing RESTful web services using Node.jsWriting RESTful web services using Node.js
Writing RESTful web services using Node.js
 
Алексей Швайка "Bundling: you are doing it wrong"
Алексей Швайка "Bundling: you are doing it wrong"Алексей Швайка "Bundling: you are doing it wrong"
Алексей Швайка "Bundling: you are doing it wrong"
 
Overview Of Lift Framework
Overview Of Lift FrameworkOverview Of Lift Framework
Overview Of Lift Framework
 
Overview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web FrameworkOverview of The Scala Based Lift Web Framework
Overview of The Scala Based Lift Web Framework
 
Node js for enterprise
Node js for enterpriseNode js for enterprise
Node js for enterprise
 
Meanstack Introduction by Kishore Chandra
Meanstack Introduction by Kishore ChandraMeanstack Introduction by Kishore Chandra
Meanstack Introduction by Kishore Chandra
 

Similar to JavaONE 2012 Using Java with HTML5 and CSS3

Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2
Asher Martin
 
HTML5 - A Whirlwind tour
HTML5 - A Whirlwind tourHTML5 - A Whirlwind tour
HTML5 - A Whirlwind tour
Lohith Goudagere Nagaraj
 
Thats Not Flash?
Thats Not Flash?Thats Not Flash?
Thats Not Flash?
Mike Wilcox
 
Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)
Adam Lu
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JS
Naga Harish M
 
Wordcamp Thessaloniki 2011 The Nextweb
Wordcamp Thessaloniki 2011 The NextwebWordcamp Thessaloniki 2011 The Nextweb
Wordcamp Thessaloniki 2011 The NextwebGeorge Kanellopoulos
 
The Image that called me - Active Content Injection with SVG Files
The Image that called me - Active Content Injection with SVG FilesThe Image that called me - Active Content Injection with SVG Files
The Image that called me - Active Content Injection with SVG FilesMario Heiderich
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
SachinSingh217687
 
SnapyX - ParisJS
SnapyX - ParisJSSnapyX - ParisJS
SnapyX - ParisJS
florianharmel
 
SnapyX
SnapyXSnapyX
SnapyXekino
 
Moving to the Client - JavaFX and HTML5
Moving to the Client - JavaFX and HTML5Moving to the Client - JavaFX and HTML5
Moving to the Client - JavaFX and HTML5
Stephen Chin
 
New Elements & Features in HTML5
New Elements & Features in HTML5New Elements & Features in HTML5
New Elements & Features in HTML5
Jamshid Hashimi
 
HTML5: An Overview
HTML5: An OverviewHTML5: An Overview
HTML5: An Overview
Nagendra Um
 
[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 Refresher[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 Refresher
Ivano Malavolta
 
WHAT IS HTML5? (at CSS Nite Osaka)
WHAT IS HTML5? (at CSS Nite Osaka)WHAT IS HTML5? (at CSS Nite Osaka)
WHAT IS HTML5? (at CSS Nite Osaka)Shumpei Shiraishi
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
Stuart (Pid) Williams
 
HTML5: An Introduction To Next Generation Web Development
HTML5: An Introduction To Next Generation Web DevelopmentHTML5: An Introduction To Next Generation Web Development
HTML5: An Introduction To Next Generation Web Development
Tilak Joshi
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
slire
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
Ran Mizrahi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Ran Mizrahi
 

Similar to JavaONE 2012 Using Java with HTML5 and CSS3 (20)

Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2Cape Cod Web Technology Meetup - 2
Cape Cod Web Technology Meetup - 2
 
HTML5 - A Whirlwind tour
HTML5 - A Whirlwind tourHTML5 - A Whirlwind tour
HTML5 - A Whirlwind tour
 
Thats Not Flash?
Thats Not Flash?Thats Not Flash?
Thats Not Flash?
 
Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JS
 
Wordcamp Thessaloniki 2011 The Nextweb
Wordcamp Thessaloniki 2011 The NextwebWordcamp Thessaloniki 2011 The Nextweb
Wordcamp Thessaloniki 2011 The Nextweb
 
The Image that called me - Active Content Injection with SVG Files
The Image that called me - Active Content Injection with SVG FilesThe Image that called me - Active Content Injection with SVG Files
The Image that called me - Active Content Injection with SVG Files
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
 
SnapyX - ParisJS
SnapyX - ParisJSSnapyX - ParisJS
SnapyX - ParisJS
 
SnapyX
SnapyXSnapyX
SnapyX
 
Moving to the Client - JavaFX and HTML5
Moving to the Client - JavaFX and HTML5Moving to the Client - JavaFX and HTML5
Moving to the Client - JavaFX and HTML5
 
New Elements & Features in HTML5
New Elements & Features in HTML5New Elements & Features in HTML5
New Elements & Features in HTML5
 
HTML5: An Overview
HTML5: An OverviewHTML5: An Overview
HTML5: An Overview
 
[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 Refresher[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 Refresher
 
WHAT IS HTML5? (at CSS Nite Osaka)
WHAT IS HTML5? (at CSS Nite Osaka)WHAT IS HTML5? (at CSS Nite Osaka)
WHAT IS HTML5? (at CSS Nite Osaka)
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
 
HTML5: An Introduction To Next Generation Web Development
HTML5: An Introduction To Next Generation Web DevelopmentHTML5: An Introduction To Next Generation Web Development
HTML5: An Introduction To Next Generation Web Development
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 

More from Helder da Rocha

Como criar um mapa temático interativo com dados abertos e D3.js
Como criar um mapa temático interativo com dados abertos e D3.jsComo criar um mapa temático interativo com dados abertos e D3.js
Como criar um mapa temático interativo com dados abertos e D3.js
Helder da Rocha
 
Transforming public data into thematic maps (TDC2019 presentation)
Transforming public data into thematic maps (TDC2019 presentation)Transforming public data into thematic maps (TDC2019 presentation)
Transforming public data into thematic maps (TDC2019 presentation)
Helder da Rocha
 
TDC 2019: transformando 
dados
públicos
em mapas interativos
TDC 2019: transformando 
dados
públicos
em mapas interativosTDC 2019: transformando 
dados
públicos
em mapas interativos
TDC 2019: transformando 
dados
públicos
em mapas interativos
Helder da Rocha
 
Padrões essenciais de mensageria para integração de sistemas
Padrões essenciais de mensageria para integração de sistemasPadrões essenciais de mensageria para integração de sistemas
Padrões essenciais de mensageria para integração de sistemas
Helder da Rocha
 
Visualização de dados e a Web
Visualização de dados e a WebVisualização de dados e a Web
Visualização de dados e a Web
Helder da Rocha
 
Eletrônica Criativa: criando circuitos com materiais alternativos
Eletrônica Criativa: criando circuitos com materiais alternativosEletrônica Criativa: criando circuitos com materiais alternativos
Eletrônica Criativa: criando circuitos com materiais alternativos
Helder da Rocha
 
Introdução à Visualização de Dados (2015)
Introdução à Visualização de Dados (2015)Introdução à Visualização de Dados (2015)
Introdução à Visualização de Dados (2015)
Helder da Rocha
 
API de segurança do Java EE 8
API de segurança do Java EE 8API de segurança do Java EE 8
API de segurança do Java EE 8
Helder da Rocha
 
Java 9, 10, 11
Java 9, 10, 11Java 9, 10, 11
Java 9, 10, 11
Helder da Rocha
 
Curso de Java Persistence API (JPA) (Java EE 7)
Curso de Java Persistence API (JPA) (Java EE 7)Curso de Java Persistence API (JPA) (Java EE 7)
Curso de Java Persistence API (JPA) (Java EE 7)
Helder da Rocha
 
Curso de Enterprise JavaBeans (EJB) (JavaEE 7)
Curso de Enterprise JavaBeans (EJB) (JavaEE 7)Curso de Enterprise JavaBeans (EJB) (JavaEE 7)
Curso de Enterprise JavaBeans (EJB) (JavaEE 7)
Helder da Rocha
 
Introdução a JPA (2010)
Introdução a JPA (2010)Introdução a JPA (2010)
Introdução a JPA (2010)
Helder da Rocha
 
Curso de RESTful WebServices em Java com JAX-RS (Java EE 7)
Curso de RESTful WebServices em Java com JAX-RS (Java EE 7)Curso de RESTful WebServices em Java com JAX-RS (Java EE 7)
Curso de RESTful WebServices em Java com JAX-RS (Java EE 7)
Helder da Rocha
 
Minicurso de Segurança em Java EE 7
Minicurso de Segurança em Java EE 7Minicurso de Segurança em Java EE 7
Minicurso de Segurança em Java EE 7
Helder da Rocha
 
Curso de WebServlets (Java EE 7)
Curso de WebServlets (Java EE 7)Curso de WebServlets (Java EE 7)
Curso de WebServlets (Java EE 7)
Helder da Rocha
 
Curso de Java: Threads
Curso de Java: ThreadsCurso de Java: Threads
Curso de Java: Threads
Helder da Rocha
 
Atualização Java 8 (2014)
Atualização Java 8 (2014)Atualização Java 8 (2014)
Atualização Java 8 (2014)
Helder da Rocha
 
Curso de Java: Introdução a lambda e Streams
Curso de Java: Introdução a lambda e StreamsCurso de Java: Introdução a lambda e Streams
Curso de Java: Introdução a lambda e Streams
Helder da Rocha
 
Threads 07: Sincronizadores
Threads 07: SincronizadoresThreads 07: Sincronizadores
Threads 07: Sincronizadores
Helder da Rocha
 
Threads 09: Paralelismo
Threads 09: ParalelismoThreads 09: Paralelismo
Threads 09: Paralelismo
Helder da Rocha
 

More from Helder da Rocha (20)

Como criar um mapa temático interativo com dados abertos e D3.js
Como criar um mapa temático interativo com dados abertos e D3.jsComo criar um mapa temático interativo com dados abertos e D3.js
Como criar um mapa temático interativo com dados abertos e D3.js
 
Transforming public data into thematic maps (TDC2019 presentation)
Transforming public data into thematic maps (TDC2019 presentation)Transforming public data into thematic maps (TDC2019 presentation)
Transforming public data into thematic maps (TDC2019 presentation)
 
TDC 2019: transformando 
dados
públicos
em mapas interativos
TDC 2019: transformando 
dados
públicos
em mapas interativosTDC 2019: transformando 
dados
públicos
em mapas interativos
TDC 2019: transformando 
dados
públicos
em mapas interativos
 
Padrões essenciais de mensageria para integração de sistemas
Padrões essenciais de mensageria para integração de sistemasPadrões essenciais de mensageria para integração de sistemas
Padrões essenciais de mensageria para integração de sistemas
 
Visualização de dados e a Web
Visualização de dados e a WebVisualização de dados e a Web
Visualização de dados e a Web
 
Eletrônica Criativa: criando circuitos com materiais alternativos
Eletrônica Criativa: criando circuitos com materiais alternativosEletrônica Criativa: criando circuitos com materiais alternativos
Eletrônica Criativa: criando circuitos com materiais alternativos
 
Introdução à Visualização de Dados (2015)
Introdução à Visualização de Dados (2015)Introdução à Visualização de Dados (2015)
Introdução à Visualização de Dados (2015)
 
API de segurança do Java EE 8
API de segurança do Java EE 8API de segurança do Java EE 8
API de segurança do Java EE 8
 
Java 9, 10, 11
Java 9, 10, 11Java 9, 10, 11
Java 9, 10, 11
 
Curso de Java Persistence API (JPA) (Java EE 7)
Curso de Java Persistence API (JPA) (Java EE 7)Curso de Java Persistence API (JPA) (Java EE 7)
Curso de Java Persistence API (JPA) (Java EE 7)
 
Curso de Enterprise JavaBeans (EJB) (JavaEE 7)
Curso de Enterprise JavaBeans (EJB) (JavaEE 7)Curso de Enterprise JavaBeans (EJB) (JavaEE 7)
Curso de Enterprise JavaBeans (EJB) (JavaEE 7)
 
Introdução a JPA (2010)
Introdução a JPA (2010)Introdução a JPA (2010)
Introdução a JPA (2010)
 
Curso de RESTful WebServices em Java com JAX-RS (Java EE 7)
Curso de RESTful WebServices em Java com JAX-RS (Java EE 7)Curso de RESTful WebServices em Java com JAX-RS (Java EE 7)
Curso de RESTful WebServices em Java com JAX-RS (Java EE 7)
 
Minicurso de Segurança em Java EE 7
Minicurso de Segurança em Java EE 7Minicurso de Segurança em Java EE 7
Minicurso de Segurança em Java EE 7
 
Curso de WebServlets (Java EE 7)
Curso de WebServlets (Java EE 7)Curso de WebServlets (Java EE 7)
Curso de WebServlets (Java EE 7)
 
Curso de Java: Threads
Curso de Java: ThreadsCurso de Java: Threads
Curso de Java: Threads
 
Atualização Java 8 (2014)
Atualização Java 8 (2014)Atualização Java 8 (2014)
Atualização Java 8 (2014)
 
Curso de Java: Introdução a lambda e Streams
Curso de Java: Introdução a lambda e StreamsCurso de Java: Introdução a lambda e Streams
Curso de Java: Introdução a lambda e Streams
 
Threads 07: Sincronizadores
Threads 07: SincronizadoresThreads 07: Sincronizadores
Threads 07: Sincronizadores
 
Threads 09: Paralelismo
Threads 09: ParalelismoThreads 09: Paralelismo
Threads 09: Paralelismo
 

Recently uploaded

zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 

Recently uploaded (20)

zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 

JavaONE 2012 Using Java with HTML5 and CSS3

  • 1. Using Java with HTML5 and CSS3 (+ the whole HTML5 world:WebSockets, SVG, etc...) Helder da Rocha Independent Java & Web professional Argo Navis Informatica Ltda. São Paulo, Brazil helder@argonavis.com.br
  • 2. Agenda • A short introduction to some cool HTML5 features • Some ideas about how to explore the power of HTML5 in Java Web apps
  • 3. Who am I? h"p://www.youtube.com/watch?v=jHteVqfKhNo   Java,  Web,  iOS  programmer,  consultant,  instructor   Java  enthusiast  since  1995   (also  actor,  musician  and  visual  arLst  :)   From  Brazil
  • 4. Java & HTML: old friends • 1995: Applets running inside HotJava & Netscape browsers • Client-side Java • First attempt at rich interactive interfaces • Before applets there was no such thing as animation and interactivity on the Web • Scripting and Netscape extensions allowed Java-HTML communication
  • 5. Today • Proprietary solutions like Flash became de facto standards for interactive client-side apps • Java became popular for server-side apps • Many tasks that would fit better on the client- side are still done on the server-side because of inconsistent browser support
  • 6. HTML5 • Still a versioned spec under W3C, but a versionless dynamic spec under WHAT-WG (Web Hypertext Application Technology Working Group) • Has among its goals to simplify HTML code and drastically reduce the need for scripting and plugins • Deals not only with graphical aspects and structure, but also with networking, multithreading, storage, etc. (which are no longer part of the official spec)
  • 7. HTML5 is not just HTML • The “HTML5 solution” includes • CSS, JavaScript, audio & video, vector graphics • But also Web sockets, geolocation, offline cache,Web workers, client-side database, local storage, etc. • More than just graphical technologies
  • 8. JSF support? • There is not yet any official support for HTML5 from HTML-generating frameworks such as JSF • HTML5 support is expected for JSF 2.2 (Java EE 7) • But any server-side Java apps can use data sent by HTML5 client-side apps
  • 9. Some cool graphical features • HTML5 Canvas • WebGL • CSS3 animations and transitions • SVG • Audio and video control
  • 10. HTML5 Canvas • API-based vector graphics 1. Place the <canvas> element somewhere (or create it via scripting)
 <canvas id=”mycanvas” width=”200″ height=”200″/> 2. Change its style if you wish
 <style> canvas {border: solid black 1px} </style> 3. Get the 2D context
 var acanvas = document.getElementById("mycanvas");
 var ctx = acanvas.getContext("2d"); 4. Use the API to paint your canvas
 ctx.fillStyle = "rgb(255,0,0)”;
 ctx.fillRect(50, 50, 100, 100);
  • 11. WebGL: 3D animations • Not really HTML5, but built on Canvas
  • 12. Saving and retrieving graphics • Server-side applications can be used to save the state of HTML5 graphics • Serializing Canvas or SVG to the server • Saving parameters that were changed by the user • Saved state may be recovered later and be used to restore page • Ex: collaborative images, signatures, etc.
  • 13. Saving the state of the canvas • You can use a Java server-side app to save the state of a canvas drawn by the client • Canvas can be converter to image via API methods (toDataUrl()) Canvas Servlet
  • 14. CSS3 transforms • 2D and 3D transforms on any element: scale, translate, rotate, etc. • Can be combined with animations and transitions • Sophisticated effects can be obtained with no scripting at all
  • 15. CSS3 animations • Declarative transitions, 3D animations and effects like shadows, reflections, etc. • Reduces the need for scripting #frente { position:absolute; top: 0px; left: 0px; -webkit-transform: translateZ(10px) scaleZ(1.2) scale(0.5); -webkit-transform-style: preserve-3d; } #verso { position:absolute; top: 0px; left: 0px; -webkit-transform: translateZ(-10px) scaleZ(1.2) scale(0.5); -webkit-transform-style: preserve-3d; } #cena { -webkit-animation: flip 8s infinite linear; -webkit-transform-style: preserve-3d; } @-webkit-keyframes flip { from { -webkit-transform: rotateY(0deg);} to {-webkit-transform: rotateY(-360deg);} }
  • 16. SVG - ScalableVector Graphics • W3C XML standard initially based on Microsoft VML and Adobe PostScript • Initially supported by Adobe and Microsoft • Can be embedded in HTML or linked via the <img> element <?xml  version="1.0"  encoding="UTF-­‐8"?>
 <svg  xmlns="http://www.w3.org/2000/svg"  
          width="100%"  height="100%">
        <circle  r="50"  cx="100"  cy="100"  fill="green"/>  
        <circle  r="50"  cx="125"  cy="125"  fill="green"  
                                                                          fill-­‐ opacity="0.5"/>  
        <circle  r="50"  cx="150"  cy="150"  fill="green"  
                                                                          fill-­‐ opacity="0.2"/>  
 </svg>
  • 17. Saving SVG • It is not as easy as saving Canvas, since it requires serializing by third-party client-side XML processors which are browser- dependent (need to save the DOM tree) • But you can easily collect data from the client side and generate SVG on the server side • Frameworks like Apache Batik can also convert SVG to images
  • 18. SVG generation • Since SVG is XML, it can be generated on the server-side using XML authoring APIs, • Can also be generated a a template by vector software (like Illustrator) and later modified (inserting DOM nodes, removing, reordering, etc.)
  • 19. Generating SVG through XSLT and Java SVG template XSLT Java component javax.xml
 APIs SVG for embedding Parameters PNG,
 PDF
  • 21. Other features • Web database • Local storage • Web workers • Web sockets • Geolocation
  • 22. Web storage • Safer local and session storage objects • Two objects which accept any properties: localStorage and sessionStorage • Ex: localStorage.field = “Hi!”; • localStorage is not shared among tabs or windows. • You can’t insert data into them directly from the server (it has to be via scripting)
  • 23. Client-side database var db = openDatabase('mydb', '1.0', 
 'hellodb', 2 * 1024 * 1024); db.transaction( function (tx) { 
 tx.executeSql(
 'CREATE TABLE IF NOT EXISTS mytable(id unique, name)'); 
 tx.executeSql(
 'INSERT INTO mytable(id, name) 
 VALUES (1, ”Jack")');
 } ); • For applications which require a lot of structured offline data (ex: animations)
  • 24. Web workers • Threading API for JavaScript • Create thread code in a JS file, and attach it to a Worker object var worker = new Worker(“worker.js”); • Attach a listener function worker.onmessage = function(evt) { alert(evt.data); }; • Send an asynchronous message worker.postMessage(“data”);
  • 25. Geolocation • Uses the navigator object to store geolocation coordinates position.coords.latitude & longitude • Once collected, you can send them anywhere • Ex: if you send them to a Java server-side application, they can be used to generate an SVG map, for example.
  • 26. Web Sockets • A completely new protocol that uses HTTP as a bootstrap • Also has an IETF spec: RFC 6455 • Allows real-time bidirectional communication (like Comet) • Requires support from both the server-side and the client-side
  • 27. Protocol • Starts with an HTTP handshake via headers • After communication is established, data packets can be exchanged • Packet format is defined by the protocol spec GET /mychat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw== Sec-WebSocket-Protocol: chat Sec-WebSocket-Version: 13 Origin: http://example.com HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk= Sec-WebSocket-Protocol: chat
  • 28. WebSocket API • Interface WebSocket(url, [protocols]) • Events onopen onerror onclose onmessage • States 0 – CONNECTING 1 – OPEN
 2 – CLOSING 3 - CLOSED • Methods send(String | blob | arraybuffer ) close()
  • 29. Client  JavaScript  API • How  to  use  it  (client-­‐side) var  ws  =  new  WebSocket("ws://localhost:8080/myapp");   ws.onopen  =  funcLon(event)  {     alert("Opened  connecLon!");     }   ws.onmessage  =  funcLon(event)  {     alert("Message:  "  +  event.data);   }   ws.onclose  =  funcLon(event)  {        alert("Closed  connecLon!");         }   ws.send("Hello  World!"); send()  method Event  handlers WebSocket  object
  • 30. What about the server side? • Still no standard. But there should be one soon (JSR 356 + Java EE 7) • You can write your own WebSocket server, of course (study the protocol and handle it with a java.net.ServerSocket or javax.servlet implementation) • You can use Glassfish+Grizzly, Jetty, JBoss, or some other proprietary solution
  • 31. Battleship Client-side var ws; function initWS() { ws = new WebSocket("ws://localhost:8080/../WSBattleship"); ws.onmessage = function(event) { if (gameStarted) { var msg = event.data.split(":"); if (msg[0] != playerId) { hitOrMiss(msg[1], msg[2]); } } alert(event.data); } } function hitOrMiss(coords, event) { if (event == 0) { markMiss(coords); } else { markHit(coords); } } function shoot(ship) { if (gameStarted && !gameFinished) { ws.send(playerId + ":" + shotPosition); } } function addShip(ship) { if (!gameStarted && totalShips < maxShips) { ships[totalShips++] = ship.id; ship.style.fill = "red"; } if (totalShips == maxShips) { ready = true; ws.send(playerId); // ready signal! } }
  • 32. WebSockets  app  using  Grizzly • Write the component & socket • Register the component using a servlet public class MyServlet extends HttpServlet { public void init(ServletConfig config) throws ServletException { WebSocketEngine.getEngine().register(new BattleShipComponent()); } } public class BattleShipComponent extends WebSocketApplication { public WebSocket createSocket(WebSocketListener... listeners) { return new BattleShipSocket(listeners); } public void onMessage(WebSocket socket, String data) { String gameData = data.split(":"); ... } } public class BattleShipSocket extends BaseServerWebSocket { public BattleShipSocket(WebSocketListener... listeners) { super(listeners); } }
  • 33. WebSockets: battleship WS Component Web Socket Web Socket Servlet WebSocket Engine 1:a2 Text Grizzly 1.9 + Glassfish 3.1.2
  • 34. Summary • Although there is no official support for HTML5 in Java Web technologies such as JSF (expected for Java EE 7), Java server-side apps can enhance client-side HTML5 apps • Information collected by HTML5 can be used as parameters for server-side processing, where many Java APIs can be used • SVG can be easily generated on the server-side and embedded into HTML pages • Canvas (and SVG) can be serialized and stored on the server • WebSocket applications require server-side support. Currently there are several Java-based proprietary solutions. JSR 356 aims to standardize this. • Of course, browser support is still the main concern
  • 35. Thank you Helder da Rocha Twitter @helderdarocha www.argonavis.com.br