sencha and spring

37
© 2013 SpringOne 2GX. All rights reserved. Do not distribute without permission. Sencha and Spring Lou Crocker, Sencha & John Ferguson, Pivotal

Upload: spring-io

Post on 10-May-2015

495 views

Category:

Technology


0 download

DESCRIPTION

Speakers: Lou Crocker and John Ferguson Much like Spring burst onto the scene and became a defacto standard for Java, Sencha is vying for a similar role in the world of HTML5. From Ext JS for desktop development, Sencha Touch for mobile, and Sencha Architect as a design tool, it has become a pervasive technology in the new paradigm of multi-client development. In this session we will use our own SpringTrader reference application to illustrate integration techniques of Spring with Sencha. We will go beyond the basic wiring of a REST call with binding results to UI components, and look at mapping the Spring MVC and Sencha MVC architectures, along with other tips and tricks to streamline your mobile application development efforts.

TRANSCRIPT

Page 1: Sencha and Spring

© 2013 SpringOne 2GX. All rights reserved. Do not distribute without permission.

Sencha and Spring Lou Crocker, Sencha & John Ferguson, Pivotal

Page 2: Sencha and Spring

S P R I N G I O C O R E : Spring Framework 4.0

Page 3: Sencha and Spring

Who are these guys?

Page 4: Sencha and Spring

John Ferguson •  Sr. Field Engineer at Pivotal •  Formally Enterprise Data and Application Architect •  Financial Services background •  <3 Music Theater •  Enjoys cats and internet memes

Page 5: Sencha and Spring

Lou Crocker •  Senior Sales Engineer •  Background in Enterprise Development and Professional

Services

Page 6: Sencha and Spring

What are we doing here? •  Sencha, Ext-JS, Touch, GXT….huh? •  Isn’t this a Spring conference? •  Building a demo live on stage •  Building with Sencha Architect •  Wait…did we just create an “app”? •  That’s child’s play. Show me a real application

Page 7: Sencha and Spring

Developers

Current problem

End Users

Consumers are demanding a universal app experience

Developers are facing challenges building universal apps

•  Same app functionality everywhere •  Experiences tailored for desktop,

mobile and tablet

•  Apps need to run everywhere •  Apps need to be managed on

disparate platforms

Page 8: Sencha and Spring

Too many application platforms!

Page 9: Sencha and Spring

The Sencha Mission

Rapid and easy development of rich web apps for the

broadest range of access devices from IE6 to the latest

table.

Page 10: Sencha and Spring

Frameworks

Sencha Touch

Sencha Ext JS

Sencha GXT

Page 11: Sencha and Spring

Sencha Ext JS

•  MVC architecture •  Robust data APIs •  Modern themes •  Rich UI widgets •  Plugin-free charting •  Big data grids •  Cross platform browser

compatibility

Page 12: Sencha and Spring

Sencha Touch

•  High performance mobile application framework

•  Cross platform apps •  Themes for each platform •  Smooth scrolling and

animations •  Multi-touch gestures •  Adaptive layouts

Page 13: Sencha and Spring

•  Visual app builder for desktop and mobileGenerate live interfacesBuild UI and code fully featured apps directly in ArchitectConnect to backends easilyBest practices generated code

Sencha Architect

Page 14: Sencha and Spring

Aren’t we at a Spring conference? The “I Wear Too Many Hats at My Company” Syndrome

•  Developers have many jobs to do •  There isn’t always a “UI” developer •  Spring developers are expected to build

Mobile Apps •  Sencha and Spring seamless integration –

logical connectivity

Page 15: Sencha and Spring

Can we just agree? •  REST is how mobile apps

communicate with backends •  Lightweight •  Easy to use •  Facilitates data binding in

Sencha Touch

Page 16: Sencha and Spring

Quick Hyper Primer How do we build REST in Spring MVC servlet-context.xml

<mvc:annotation-driven />

Controller @Controller public class MyController {

@RequestMapping(value=“/resource/{id}”, method=RequestMethod.GET) public @RequestBody MyResource getResource(@PathVariable(“id”) int id){ return dataSource.get(id); }

}

Page 17: Sencha and Spring

How REST-y do we we need to be?

* This slide is shamelessly stolen from Josh Long @starbuxman

http://martinfowler.com/articles/richardsonMaturityModel.html

The Richardson Maturity Model is a way to grade your API according to the REST constraints with 4 levels of increasing compliance

Page 18: Sencha and Spring

What do we need?

•  Need resources so we can map back to UI domain

•  Need Verbs so we can use GET/POST/PUT/DELETE consistently

•  Hypermedia Controls / HATEOAS not important today but Sencha can take advantage of in future

Page 19: Sencha and Spring

Wait… Hatie Oh Ah Es? HATEOAS: Hypermedia As The Engine Of Application State

•  Uniform interface •  Rels in Links provide standard

access to related resources

http://www.youtube.com/watch?v=SC0FPuDKei0

Better explanation:

Page 20: Sencha and Spring

Quick Hyper Primer How do we build REST in Spring MVC servlet-context.xml

<mvc:annotation-driven />

Controller @Controller public class MyController {

@RequestMapping(value=“/resource/{id}”, method=RequestMethod.GET) public @RequestBody MyResource getResource(@PathVariable(“id”) int id){ return dataSource.get(id); }

}

Level 1: Resources

Level 2: HTTP Verbs

Page 21: Sencha and Spring

Some things to think about… •  Models Matter

–  Mobile clients need to know how the objects are returned •  REST consistency matters

–  Can’t change the URL’s willy-nilly •  Thinner objects are better than monothlic

–  Many times you are sending data over mobile network •  JSONP is your friend for development

Page 22: Sencha and Spring

D E M O

Page 23: Sencha and Spring

Spring Twitter Search •  Spring REST back end •  Query will return last 10 tweets to match •  Wrap it in JSONP to enable cross-site json •  Sencha Touch front-end •  What is this Spring 2012? A twitter app? You bet!

Page 24: Sencha and Spring

Building a Spring Twitter backend

Page 25: Sencha and Spring

Or do they….

Page 26: Sencha and Spring

Add a little Spring Social

Page 27: Sencha and Spring

..and we have data!

Page 28: Sencha and Spring

Building a Twitter search app •  Let’s begin with Architect •  The project structure •  Add the container •  Add the view •  Create the Model •  Create the store •  Bind the view

Page 29: Sencha and Spring

Access static electricity resource in Spring

Page 30: Sencha and Spring

Combine the pieces … and deploy! •  Test the data in the design environment •  Create the display template •  Create the preview path •  Preview the app •  Set the build path •  Build the app •  Modify template/theme/parameters and repeat

Page 31: Sencha and Spring

Let’s start trending!

http://ssawesome123.cfapps.io/app.html

Tweet with hashtag:

#ssawesome

Page 32: Sencha and Spring

Spring Trader •  Reference Architecture for Pivotal and Spring •  Inspired by IBM “Day Trader” •  Uses Spring MVC to expose REST endpoints

–  Level 2: HTTP verbs •  Sencha Touch front end

http://springtrader.gopivotal.com/spring-nanotrader-sencha/

https://github.com/vFabric/springtrader/tree/sencha-mobile Github:

Live Application:

Page 33: Sencha and Spring
Page 34: Sencha and Spring

Spring Trader Architecture

Page 35: Sencha and Spring

Spring Trader Architecture

Page 36: Sencha and Spring

Keeping up with us

John Ferguson Email: [email protected] twitter: fergusonjohnw Lou Crocker Email: [email protected] web: www.sencha.com

Page 37: Sencha and Spring