25
Techniques For Responsive Real-Time Web User Interfaces Roger Kitain Principal Member Technical Staff

Con5133

Embed Size (px)

DESCRIPTION

JavaOne 2012 Real-time (HTML5) presentation.

Citation preview

Page 1: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 1

Techniques For Responsive Real-Time Web User Interfaces

Roger Kitain

Principal Member Technical Staff

Page 2: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 2

Background

Primary responsibility: JSF at Oracle

JSF Co-spec lead for 1.2, 2.0

Work related passion: Client side, JavaScript, Real-time web

communication

Hobbies: Music (Guitar), Hockey, Robotics, code slinger, all things

cool!

Who Am I?

Page 3: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 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: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 4

Program Agenda

Introduction

The Real-Time Web

User Interface Techniques

Demos

Summary

Page 5: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 5

Ben Maddux

Dave Barry

“Twitter is just a multiplayer notepad.”

“The internet: Transforming Society

And Shaping the Future Through Chat”

Page 6: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 6

Introduction

Traditional web: request / response model

– Based on HTTP

– No server initiated events

Dynamic web:

– Web more dynamic since 1990’s

– Java Applets (1995), iframe (1996),

JavaScript, DHTML, Ajax

Page 7: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 7

The Real-time Web

Traditional Patterns

Page 8: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 8

The Real-time Web

Traditional Technologies

Partial Page Refresh

Real-time through polling

No standard implementation

Complex: HTTP not designed to

send unrequested server

responses

Page 9: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 9

Real-time Communication

Web page subscribes to a stream of DOM events from server

Unidirectional: events form server to client (over HTTP)

Evolved from April 2004 proposal:

– http://ln.hixie.ch/?count=1&start=1083167110

Specification:

– http://www.w3.org/TR/eventsource/

Server Sent Events : HTML5 “Streaming”

Page 10: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 10

Real-time Communication

Server Sent Events : Client

Page 11: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 11

Real-time Communication

Bidirectional client / server connection

HTTP for initial handshake

Connection: upgrade from HTTP to WS protocol

Data sent in frames – Each frame (example):

\0x00Hello World\0xff Data (Hello World) is UTF-8

Web Sockets: HTML5 “Full Duplex”

Page 12: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 12

Real-time Communication

Web Sockets : Client

Page 13: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 13

User Interface Techniques

Based on JSF 2.x component model and JavaScript

Encapsulate HTML5 JavaScript API within JSF component.

Connection established when page loads

JSF component may also render “placeholder” markup for receiving

message data.

Works for Server Sent Events, Web Socket

Component Pattern

Page 14: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 14

User Interface Techniques

Use Java API to start a connection from a model bean action method

Connection established as the result of some user action

JSF component may also render “placeholder” markup for receiving

message data.

Consider how to handle connection when bean goes out of scope

Model Pattern

Page 15: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 15

DEMO

Page 16: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 16

Real-time Web

Use Case: Device Control

Physical

Device Web Socket

Server

Page 17: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 17

DEMO

Page 18: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 18

Real-time Web

Use Case: Device Control

Physical

Device

Web Socket

Server

Socket

Handler Bean Device

SDK

Browser

Client

JavaScript

API

Page 19: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 19

HTML5 Technology Availability

http://caniuse.com

http://feeds.feedburner.com/WhenCanIUse

Useful Resources

Page 20: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 20

HTML5 Technology

Availability

Page 21: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 21

HTML5 Technology

Availability

Page 22: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 22

Summary

Traditional web / dynamic web

Traditional patterns / technologies

Real-time communication (HTML5)

User interface techniques

Use cases

Page 23: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 23

References

http://thethirdstone.com

http://java.net/projects/websocket-spec

http://jcp.org/en/jsr/detail?id=356

Page 24: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 24

Q & A

Page 25: Con5133

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 13 25

Graphic Section Divider