SlideShare a Scribd company logo
Extending Spring MVC with
                            Spring Mobile and JavaScript
                              Roy Clarkson, Spring Mobile/Android Project Lead
                                   Craig Walls, Spring Social Project Lead
                                  Twitter/Github: @royclarkson, @habuma


© 2012 SpringOne 2GX. All rights reserved. Do not distribute without permission.
The Changing Face of the Web




4
The Changing Face of the Web




4
The Changing Face of the Web




4
The Changing Face of the Web




4
The Changing Face of the Web




4
The Changing Face of the Web




4
The Changing Face of the Web




4
The Changing Face of the Web




4
Targeting the Diverse Internet Client

        Your applications, anytime, anywhere, on any device

             Each platform has different physical capabilities

                  Same application/different experience

Experience customized to suit the capabilities/limits of the target platform




4
The Solution: Separate Web Sites per Platform


     Create a unique (aesthetically and functionally) site for...
                          Desktop browsers
      Handhelds (iPhone, various Android phones, iPod Touch)
               Tablets (iPad, various Android tablets)

                 Now you have a new problem
           Code duplication across platform-specific sites




4
Addendum to Previous Solution

                         Spring Mobile
                    Extension to Spring MVC
            Directs requests to platform-specific sites

                     Lumbar (and Thorax)
            From Walmart Labs (yes, that Walmart)
             Build tool for JavaScript client projects
           Identify collateral common to all platforms
           And collateral specific to certain platforms
                     Builds site-per-platform
           Thorax: Opinionated Backbone framework
4
Targeting the Right Platform
                                   with Spring Mobile



© 2012 SpringOne 2GX. All rights reserved. Do not distribute without permission.
Spring Mobile
• Provides support for developing mobile web applications
• Extension to Spring MVC, for server-side support
• Compliments client-side mobile frameworks




 7
Features
• Device Detection
• Site Preference Management
• Site Switcher




 8
Device Detection
• Differentiate requests from various devices
• Introspects HTTP requests to determine the device that
  originated the request
• Provides a DeviceResolver abstraction and interceptor
• LiteDeviceResolver implementation




 9
Device Resolver
 <annotation-driven>

     <argument-resolvers>

         <beans:bean class="org.springframework.mobile.device
             .DeviceWebArgumentResolver" />

     </argument-resolvers>

 </annotation-driven>

 <interceptors>

 !   <beans:bean class="org.springframework.mobile.device
         .DeviceResolverHandlerInterceptor" />
 !
 </interceptors>

10
Device Injection

 @Controller
 public class HomeController {

     @RequestMapping("/")
     public void home(Device device) {
         if (device.isMobile()) {
             // Hello mobile user!
         } else {
             // Hello desktop user!
         }
     }

 }




11
Device Detection Demo




12
Site Preference Management
• Allows the user to indicate whether he or she prefers the
  mobile site or the normal site
• Remembers the user’s preference for their session
• StandardSitePreferenceHandler implementation




 13
Site Preference Resolver


 <annotation-driven>

 !   <argument-resolvers>

 !   !   <beans:bean class="org.springframework.mobile.device.site
            .SitePreferenceWebArgumentResolver" />

 !   </argument-resolvers>

 </annotation-driven>




14
SitePreference Injection

 @Controller
 public class HomeController {

     @RequestMapping("/")
 !   public String home(SitePreference sitePreference, Model model) {
 !   !    if (sitePreference == SitePreference.MOBILE) {
 !   !    !   return "home-mobile";
 !   !    } else {
 !   !    !   return "home";
 !   !    }
 !   }

 }



15
Site Preference Demo




16
Site Switcher
• Some applications may wish to host their "mobile site" at a
  different domain from their "normal site"
• SiteSwitcherHandlerInterceptor can be used to redirect
  mobile users to a dedicated mobile site
• Supported SiteSwitchers
      – mDot
      – dotMobi
      – urlPath


 17
“mDot” Site Switcher


 <interceptors>
 !
     <beans:bean class="org.springframework.mobile.device.switcher
         .SiteSwitcherHandlerInterceptor" factory-method="mDot">

         <beans:constructor-arg value="testdomain.com" />

     </beans:bean>
 !   !
 </interceptors>




18
“dotMobi” Site Switcher


 <interceptors>
 !
     <beans:bean class="org.springframework.mobile.device.switcher
         .SiteSwitcherHandlerInterceptor" factory-method="dotMobi">

         <beans:constructor-arg value="testdomain.com" />

     </beans:bean>
 !   !
 </interceptors>




19
“urlPath” Site Switcher

 <interceptors>
 !
     <beans:bean class="org.springframework.mobile.device.switcher
         .SiteSwitcherHandlerInterceptor" factory-method="urlPath">

         <beans:constructor-arg value="/m" />
         <beans:constructor-arg value="/showcase" />

     </beans:bean>
 !   !
 </interceptors>




20
Site Switcher Demo




21
Building Platform-Targeted Sites
                          with Lumbar (and Thorax)



© 2012 SpringOne 2GX. All rights reserved. Do not distribute without permission.
Introducing Thorax

                Opinionated Backbone Framework
                  Project structure and scaffolding
                    On-demand module loading
                   Model/collection view binding
                 Inheritable view and DOM events
                        Data loading helpers
                   Form serialization/population
                           Form validation

Based on Backbone, Underscore, Zepto, Handlebars, Stylus, and Lumbar

4
Introducing Lumbar



                    JavaScript Build Tool
                Works from a general codebase
                    With a list of platforms
         Generates modular, platform-specific applications
                 Works best with Backbone/Thorax
                      Pluggable architecture




4
Getting and Installing Thorax and Lumbar

                        Prerequisites
                        Node and npm

                         Quick Start*
              % npm install -g lumbar thorax@1.2.1
              % thorax create MyProject
              % cd MyProject
              % lumbar build lumbar.json public
              % npm start

                                                     * Adapted from Thorax website
4
Elements of a Lumbar Build File (lumbar.json)


               Application: Defines the root module

       Platforms: Target platforms (e.g., iPhone, Android, etc)

    Packages: Macro-level definition of what goes into a platform

                Modules: Logical groupings of code

        Templates: Client-side templates (e.g. Handlebars)

          Styles: Stylesheets to be compiled (e.g. Stylus)


4
A Peek Inside lumbar.json




    {
        "application": {
           "name": "Application",
           "module": "base"
        },
        "platforms": [ "android", "iphone", "ipad", "web" ],
        "packages": { ... }
        "modules": { ... },
        "templates": { ... },
        "styles": { ... }
    }




4
A Peek Inside lumbar.json

    {
        "application": {...},
        "platforms": [ ... ],
        "packages": {
           "web": {
              "platforms": [ "web" ],
              "combine": false
           },
           "native-hello-world": {
              "platforms": [ "android", "iphone", "ipad" ],
              "modules": [ "base", "hello_world" ],
              "combine": true
           }
        },
        "modules": { ... },
        "templates": { ... },
        "styles": { ... }
    }


4
A Peek Inside lumbar.json
    { "application": {...}, "platforms": [ ... ], "packages": { ... },
      "modules": {
         "base": {
           "scripts": [
              {"src": "js/lib/zepto.js", "global": true},
              {"src": "js/lib/underscore.js", "global": true},
              ...
           ],
           "styles": [
              "styles/base.styl",
              {"src": "styles/iphone.styl", "platform": "iphone"},
              ...
           ],
           "static": [
              {"src": "static/#{platform}/index.html", "dest": "index.html"}
           ]
          }, "hello_world" : { ... }
      },
      "templates": { ... },   "styles": { ... }   }


4
A Peek Inside lumbar.json




    {
        "application": { ... },
        "platforms": [ ... ],
        "packages": { ... }
        "modules": { ... },
        "templates": {
           "js/views/hello_world/index.js": [
             "templates/hello_world/index.handlebars"
           ]
        },
        "styles": { ... }
    }




4
A Peek Inside lumbar.json

    {
        "application": { ... },
        "platforms": [ "android", "iphone", "ipad", "web" ],
        "packages": { ... }
        "modules": { ... },
        "templates": { ... },
        "styles": {
          "pixelDensity": {
             "android": [ 1, 1.5 ],
             "iphone": [ 1, 2 ],
             "ipad" : [ 1, 2 ],
             "web": [ 1, 2 ]
          },
          "includes": [
             "nib",
             "styles/include/global.styl"
          ]
        }
    }

4
Building with Lumbar
                                    .
                                    !""   android
                                    #     !"" index.html
                                    #     !"" native-hello-world.css
                                    #     !"" native-hello-world.js
                                    #     $"" native-hello-world@1.5x.css
      At command-line               !""   index.html
                                    !""   ipad
% lumbar build lumbar.json public   #  
                                    #  
                                          !"" index.html
                                          !"" native-hello-world.css
                                    #     !"" native-hello-world.js
                                    #     $"" native-hello-world@2x.css
                                    !""   iphone
         What you get               #     !"" index.html
                                    #     !"" native-hello-world.css
                                    #     !"" native-hello-world.js
                                    #     $"" native-hello-world@2x.css
                                    $""   web
                                          !"" base.css
                                          !"" base.js
                                          !"" base@2x.css
                                          !"" hello_world.css
                                          !"" hello_world.js
                                          !"" hello_world@2x.css
                                          $"" index.html


4
Demo: Thorax Client
Conclusion




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

         The web is consumed by many different kinds of clients

       Each client platform has unique capabilities and limitations

              Web applications should target each platform

                 Same application / different experience

Lumbar can build platform-specific applications from a general codebase

Spring Mobile can detect the platform and direct to a platform-specific site


4
Q&A




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

More Related Content

What's hot (20)

Intro to Ionic for Building Hybrid Mobile Applications
Intro to Ionic for Building Hybrid Mobile ApplicationsIntro to Ionic for Building Hybrid Mobile Applications
Intro to Ionic for Building Hybrid Mobile Applications
Sasha dos Santos
 
Ionic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application DevelopmentIonic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application Development
Justin James
 
Developing Hybrid Applications with IONIC
Developing Hybrid Applications with IONICDeveloping Hybrid Applications with IONIC
Developing Hybrid Applications with IONIC
Fuat Buğra AYDIN
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
Troy Miles
 
Wikipedia Mobile App with PhoneGap
Wikipedia Mobile App with PhoneGapWikipedia Mobile App with PhoneGap
Wikipedia Mobile App with PhoneGap
Ted Chien
 
Selendroid - Selenium for Android
Selendroid - Selenium for AndroidSelendroid - Selenium for Android
Selendroid - Selenium for Android
Dominik Dary
 
Ionic Framework: Let's build amazing apps. No Excuses!
Ionic Framework: Let's build amazing apps. No Excuses!Ionic Framework: Let's build amazing apps. No Excuses!
Ionic Framework: Let's build amazing apps. No Excuses!
Matheus Cardoso
 
Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)
ejlp12
 
Hybrid app development with ionic
Hybrid app development with ionicHybrid app development with ionic
Hybrid app development with ionic
Wan Muzaffar Wan Hashim
 
Ionic Mobile Applications - Hybrid Mobile Applications Without Compromises
Ionic Mobile Applications - Hybrid Mobile Applications Without CompromisesIonic Mobile Applications - Hybrid Mobile Applications Without Compromises
Ionic Mobile Applications - Hybrid Mobile Applications Without Compromises
Jacob Friesen
 
Lesson 1. Create project Sunshine
Lesson 1. Create project SunshineLesson 1. Create project Sunshine
Lesson 1. Create project Sunshine
Chanhyeong LEE
 
Cross-platform development frameworks
Cross-platform development frameworksCross-platform development frameworks
Cross-platform development frameworks
Carlo Bernaschina
 
Ionic Framework
Ionic FrameworkIonic Framework
Ionic Framework
Thinh VoXuan
 
Angularjs Tutorial for Beginners
Angularjs Tutorial for BeginnersAngularjs Tutorial for Beginners
Angularjs Tutorial for Beginners
rajkamaltibacademy
 
IONIC - Hybrid Mobile App Development
IONIC - Hybrid Mobile App DevelopmentIONIC - Hybrid Mobile App Development
IONIC - Hybrid Mobile App Development
Malan Amarasinghe
 
Appcelerator Titanium Intro
Appcelerator Titanium IntroAppcelerator Titanium Intro
Appcelerator Titanium Intro
Nicholas Jansma
 
jQuery Conference Boston 2011 CouchApps
jQuery Conference Boston 2011 CouchAppsjQuery Conference Boston 2011 CouchApps
jQuery Conference Boston 2011 CouchApps
Bradley Holt
 
Being Epic: Best Practices for Android Development
Being Epic: Best Practices for Android DevelopmentBeing Epic: Best Practices for Android Development
Being Epic: Best Practices for Android Development
Reto Meier
 
Apache cordova
Apache cordovaApache cordova
Apache cordova
Carlo Bernaschina
 
Samsung Devcon - State of HTML5 - Chris Heilmann
Samsung Devcon - State of HTML5 - Chris HeilmannSamsung Devcon - State of HTML5 - Chris Heilmann
Samsung Devcon - State of HTML5 - Chris Heilmann
Christian Heilmann
 
Intro to Ionic for Building Hybrid Mobile Applications
Intro to Ionic for Building Hybrid Mobile ApplicationsIntro to Ionic for Building Hybrid Mobile Applications
Intro to Ionic for Building Hybrid Mobile Applications
Sasha dos Santos
 
Ionic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application DevelopmentIonic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application Development
Justin James
 
Developing Hybrid Applications with IONIC
Developing Hybrid Applications with IONICDeveloping Hybrid Applications with IONIC
Developing Hybrid Applications with IONIC
Fuat Buğra AYDIN
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
Troy Miles
 
Wikipedia Mobile App with PhoneGap
Wikipedia Mobile App with PhoneGapWikipedia Mobile App with PhoneGap
Wikipedia Mobile App with PhoneGap
Ted Chien
 
Selendroid - Selenium for Android
Selendroid - Selenium for AndroidSelendroid - Selenium for Android
Selendroid - Selenium for Android
Dominik Dary
 
Ionic Framework: Let's build amazing apps. No Excuses!
Ionic Framework: Let's build amazing apps. No Excuses!Ionic Framework: Let's build amazing apps. No Excuses!
Ionic Framework: Let's build amazing apps. No Excuses!
Matheus Cardoso
 
Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)Introduction to Apache Cordova (Phonegap)
Introduction to Apache Cordova (Phonegap)
ejlp12
 
Ionic Mobile Applications - Hybrid Mobile Applications Without Compromises
Ionic Mobile Applications - Hybrid Mobile Applications Without CompromisesIonic Mobile Applications - Hybrid Mobile Applications Without Compromises
Ionic Mobile Applications - Hybrid Mobile Applications Without Compromises
Jacob Friesen
 
Lesson 1. Create project Sunshine
Lesson 1. Create project SunshineLesson 1. Create project Sunshine
Lesson 1. Create project Sunshine
Chanhyeong LEE
 
Cross-platform development frameworks
Cross-platform development frameworksCross-platform development frameworks
Cross-platform development frameworks
Carlo Bernaschina
 
Angularjs Tutorial for Beginners
Angularjs Tutorial for BeginnersAngularjs Tutorial for Beginners
Angularjs Tutorial for Beginners
rajkamaltibacademy
 
IONIC - Hybrid Mobile App Development
IONIC - Hybrid Mobile App DevelopmentIONIC - Hybrid Mobile App Development
IONIC - Hybrid Mobile App Development
Malan Amarasinghe
 
Appcelerator Titanium Intro
Appcelerator Titanium IntroAppcelerator Titanium Intro
Appcelerator Titanium Intro
Nicholas Jansma
 
jQuery Conference Boston 2011 CouchApps
jQuery Conference Boston 2011 CouchAppsjQuery Conference Boston 2011 CouchApps
jQuery Conference Boston 2011 CouchApps
Bradley Holt
 
Being Epic: Best Practices for Android Development
Being Epic: Best Practices for Android DevelopmentBeing Epic: Best Practices for Android Development
Being Epic: Best Practices for Android Development
Reto Meier
 
Samsung Devcon - State of HTML5 - Chris Heilmann
Samsung Devcon - State of HTML5 - Chris HeilmannSamsung Devcon - State of HTML5 - Chris Heilmann
Samsung Devcon - State of HTML5 - Chris Heilmann
Christian Heilmann
 

Similar to Extending Spring MVC with Spring Mobile and JavaScript (20)

[2015/2016] Apache Cordova
[2015/2016] Apache Cordova[2015/2016] Apache Cordova
[2015/2016] Apache Cordova
Ivano Malavolta
 
Drupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source AppDrupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source App
littleMAS
 
Apache Cordova 4.x
Apache Cordova 4.xApache Cordova 4.x
Apache Cordova 4.x
Ivano Malavolta
 
Universal Applications with Universal JavaScript
Universal Applications with Universal JavaScriptUniversal Applications with Universal JavaScript
Universal Applications with Universal JavaScript
Thomas Joseph
 
Apache Cordova
Apache CordovaApache Cordova
Apache Cordova
Ivano Malavolta
 
Native - Hybrid - Web Mobile Architectures
Native - Hybrid - Web Mobile ArchitecturesNative - Hybrid - Web Mobile Architectures
Native - Hybrid - Web Mobile Architectures
Phong Le Duy
 
Introduction phonegap
Introduction phonegapIntroduction phonegap
Introduction phonegap
Rakesh Jha
 
Advanced programing in phonegap
Advanced programing in phonegapAdvanced programing in phonegap
Advanced programing in phonegap
Rakesh Jha
 
Angular mobile angular_u
Angular mobile angular_uAngular mobile angular_u
Angular mobile angular_u
Doris Chen
 
Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18
Pierre Joye
 
Mobile Vue.js – From PWA to Native
Mobile Vue.js – From PWA to NativeMobile Vue.js – From PWA to Native
Mobile Vue.js – From PWA to Native
MartinSotirov
 
Talk (2)
Talk (2)Talk (2)
Talk (2)
suraj sakhardande
 
Dojo mobile web5-2013
Dojo mobile web5-2013Dojo mobile web5-2013
Dojo mobile web5-2013
cjolif
 
2.28.17 Introducing DSpace 7 Webinar Slides
2.28.17 Introducing DSpace 7 Webinar Slides2.28.17 Introducing DSpace 7 Webinar Slides
2.28.17 Introducing DSpace 7 Webinar Slides
DuraSpace
 
Building Effective and Rapid Applications with IBM MobileFirst Platform
Building Effective and Rapid Applications with IBM MobileFirst PlatformBuilding Effective and Rapid Applications with IBM MobileFirst Platform
Building Effective and Rapid Applications with IBM MobileFirst Platform
Andrew Ferrier
 
Titanium appcelerator best practices
Titanium appcelerator best practicesTitanium appcelerator best practices
Titanium appcelerator best practices
Alessio Ricco
 
HTML5 Can't Do That
HTML5 Can't Do ThatHTML5 Can't Do That
HTML5 Can't Do That
Nathan Smith
 
Ionic Framework - get up and running to build hybrid mobile apps
Ionic Framework - get up and running to build hybrid mobile appsIonic Framework - get up and running to build hybrid mobile apps
Ionic Framework - get up and running to build hybrid mobile apps
Andreas Sahle
 
Fixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World RomaniaFixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World Romania
Christian Heilmann
 
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile FrameworkBuilding a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
St. Petersburg College
 
[2015/2016] Apache Cordova
[2015/2016] Apache Cordova[2015/2016] Apache Cordova
[2015/2016] Apache Cordova
Ivano Malavolta
 
Drupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source AppDrupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source App
littleMAS
 
Universal Applications with Universal JavaScript
Universal Applications with Universal JavaScriptUniversal Applications with Universal JavaScript
Universal Applications with Universal JavaScript
Thomas Joseph
 
Native - Hybrid - Web Mobile Architectures
Native - Hybrid - Web Mobile ArchitecturesNative - Hybrid - Web Mobile Architectures
Native - Hybrid - Web Mobile Architectures
Phong Le Duy
 
Introduction phonegap
Introduction phonegapIntroduction phonegap
Introduction phonegap
Rakesh Jha
 
Advanced programing in phonegap
Advanced programing in phonegapAdvanced programing in phonegap
Advanced programing in phonegap
Rakesh Jha
 
Angular mobile angular_u
Angular mobile angular_uAngular mobile angular_u
Angular mobile angular_u
Doris Chen
 
Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18Webdevcon Keynote hh-2012-09-18
Webdevcon Keynote hh-2012-09-18
Pierre Joye
 
Mobile Vue.js – From PWA to Native
Mobile Vue.js – From PWA to NativeMobile Vue.js – From PWA to Native
Mobile Vue.js – From PWA to Native
MartinSotirov
 
Dojo mobile web5-2013
Dojo mobile web5-2013Dojo mobile web5-2013
Dojo mobile web5-2013
cjolif
 
2.28.17 Introducing DSpace 7 Webinar Slides
2.28.17 Introducing DSpace 7 Webinar Slides2.28.17 Introducing DSpace 7 Webinar Slides
2.28.17 Introducing DSpace 7 Webinar Slides
DuraSpace
 
Building Effective and Rapid Applications with IBM MobileFirst Platform
Building Effective and Rapid Applications with IBM MobileFirst PlatformBuilding Effective and Rapid Applications with IBM MobileFirst Platform
Building Effective and Rapid Applications with IBM MobileFirst Platform
Andrew Ferrier
 
Titanium appcelerator best practices
Titanium appcelerator best practicesTitanium appcelerator best practices
Titanium appcelerator best practices
Alessio Ricco
 
HTML5 Can't Do That
HTML5 Can't Do ThatHTML5 Can't Do That
HTML5 Can't Do That
Nathan Smith
 
Ionic Framework - get up and running to build hybrid mobile apps
Ionic Framework - get up and running to build hybrid mobile appsIonic Framework - get up and running to build hybrid mobile apps
Ionic Framework - get up and running to build hybrid mobile apps
Andreas Sahle
 
Fixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World RomaniaFixing the mobile web - Internet World Romania
Fixing the mobile web - Internet World Romania
Christian Heilmann
 
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile FrameworkBuilding a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
St. Petersburg College
 
Ad

Recently uploaded (20)

Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Ad

Extending Spring MVC with Spring Mobile and JavaScript

  • 1. Extending Spring MVC with Spring Mobile and JavaScript Roy Clarkson, Spring Mobile/Android Project Lead Craig Walls, Spring Social Project Lead Twitter/Github: @royclarkson, @habuma © 2012 SpringOne 2GX. All rights reserved. Do not distribute without permission.
  • 2. The Changing Face of the Web 4
  • 3. The Changing Face of the Web 4
  • 4. The Changing Face of the Web 4
  • 5. The Changing Face of the Web 4
  • 6. The Changing Face of the Web 4
  • 7. The Changing Face of the Web 4
  • 8. The Changing Face of the Web 4
  • 9. The Changing Face of the Web 4
  • 10. Targeting the Diverse Internet Client Your applications, anytime, anywhere, on any device Each platform has different physical capabilities Same application/different experience Experience customized to suit the capabilities/limits of the target platform 4
  • 11. The Solution: Separate Web Sites per Platform Create a unique (aesthetically and functionally) site for... Desktop browsers Handhelds (iPhone, various Android phones, iPod Touch) Tablets (iPad, various Android tablets) Now you have a new problem Code duplication across platform-specific sites 4
  • 12. Addendum to Previous Solution Spring Mobile Extension to Spring MVC Directs requests to platform-specific sites Lumbar (and Thorax) From Walmart Labs (yes, that Walmart) Build tool for JavaScript client projects Identify collateral common to all platforms And collateral specific to certain platforms Builds site-per-platform Thorax: Opinionated Backbone framework 4
  • 13. Targeting the Right Platform with Spring Mobile © 2012 SpringOne 2GX. All rights reserved. Do not distribute without permission.
  • 14. Spring Mobile • Provides support for developing mobile web applications • Extension to Spring MVC, for server-side support • Compliments client-side mobile frameworks 7
  • 15. Features • Device Detection • Site Preference Management • Site Switcher 8
  • 16. Device Detection • Differentiate requests from various devices • Introspects HTTP requests to determine the device that originated the request • Provides a DeviceResolver abstraction and interceptor • LiteDeviceResolver implementation 9
  • 17. Device Resolver <annotation-driven> <argument-resolvers> <beans:bean class="org.springframework.mobile.device .DeviceWebArgumentResolver" /> </argument-resolvers> </annotation-driven> <interceptors> ! <beans:bean class="org.springframework.mobile.device .DeviceResolverHandlerInterceptor" /> ! </interceptors> 10
  • 18. Device Injection @Controller public class HomeController { @RequestMapping("/") public void home(Device device) { if (device.isMobile()) { // Hello mobile user! } else { // Hello desktop user! } } } 11
  • 20. Site Preference Management • Allows the user to indicate whether he or she prefers the mobile site or the normal site • Remembers the user’s preference for their session • StandardSitePreferenceHandler implementation 13
  • 21. Site Preference Resolver <annotation-driven> ! <argument-resolvers> ! ! <beans:bean class="org.springframework.mobile.device.site .SitePreferenceWebArgumentResolver" /> ! </argument-resolvers> </annotation-driven> 14
  • 22. SitePreference Injection @Controller public class HomeController { @RequestMapping("/") ! public String home(SitePreference sitePreference, Model model) { ! ! if (sitePreference == SitePreference.MOBILE) { ! ! ! return "home-mobile"; ! ! } else { ! ! ! return "home"; ! ! } ! } } 15
  • 24. Site Switcher • Some applications may wish to host their "mobile site" at a different domain from their "normal site" • SiteSwitcherHandlerInterceptor can be used to redirect mobile users to a dedicated mobile site • Supported SiteSwitchers – mDot – dotMobi – urlPath 17
  • 25. “mDot” Site Switcher <interceptors> ! <beans:bean class="org.springframework.mobile.device.switcher .SiteSwitcherHandlerInterceptor" factory-method="mDot"> <beans:constructor-arg value="testdomain.com" /> </beans:bean> ! ! </interceptors> 18
  • 26. “dotMobi” Site Switcher <interceptors> ! <beans:bean class="org.springframework.mobile.device.switcher .SiteSwitcherHandlerInterceptor" factory-method="dotMobi"> <beans:constructor-arg value="testdomain.com" /> </beans:bean> ! ! </interceptors> 19
  • 27. “urlPath” Site Switcher <interceptors> ! <beans:bean class="org.springframework.mobile.device.switcher .SiteSwitcherHandlerInterceptor" factory-method="urlPath"> <beans:constructor-arg value="/m" /> <beans:constructor-arg value="/showcase" /> </beans:bean> ! ! </interceptors> 20
  • 29. Building Platform-Targeted Sites with Lumbar (and Thorax) © 2012 SpringOne 2GX. All rights reserved. Do not distribute without permission.
  • 30. Introducing Thorax Opinionated Backbone Framework Project structure and scaffolding On-demand module loading Model/collection view binding Inheritable view and DOM events Data loading helpers Form serialization/population Form validation Based on Backbone, Underscore, Zepto, Handlebars, Stylus, and Lumbar 4
  • 31. Introducing Lumbar JavaScript Build Tool Works from a general codebase With a list of platforms Generates modular, platform-specific applications Works best with Backbone/Thorax Pluggable architecture 4
  • 32. Getting and Installing Thorax and Lumbar Prerequisites Node and npm Quick Start* % npm install -g lumbar [email protected] % thorax create MyProject % cd MyProject % lumbar build lumbar.json public % npm start * Adapted from Thorax website 4
  • 33. Elements of a Lumbar Build File (lumbar.json) Application: Defines the root module Platforms: Target platforms (e.g., iPhone, Android, etc) Packages: Macro-level definition of what goes into a platform Modules: Logical groupings of code Templates: Client-side templates (e.g. Handlebars) Styles: Stylesheets to be compiled (e.g. Stylus) 4
  • 34. A Peek Inside lumbar.json { "application": { "name": "Application", "module": "base" }, "platforms": [ "android", "iphone", "ipad", "web" ], "packages": { ... } "modules": { ... }, "templates": { ... }, "styles": { ... } } 4
  • 35. A Peek Inside lumbar.json { "application": {...}, "platforms": [ ... ], "packages": { "web": { "platforms": [ "web" ], "combine": false }, "native-hello-world": { "platforms": [ "android", "iphone", "ipad" ], "modules": [ "base", "hello_world" ], "combine": true } }, "modules": { ... }, "templates": { ... }, "styles": { ... } } 4
  • 36. A Peek Inside lumbar.json { "application": {...}, "platforms": [ ... ], "packages": { ... }, "modules": { "base": { "scripts": [ {"src": "js/lib/zepto.js", "global": true}, {"src": "js/lib/underscore.js", "global": true}, ... ], "styles": [ "styles/base.styl", {"src": "styles/iphone.styl", "platform": "iphone"}, ... ], "static": [ {"src": "static/#{platform}/index.html", "dest": "index.html"} ] }, "hello_world" : { ... } }, "templates": { ... }, "styles": { ... } } 4
  • 37. A Peek Inside lumbar.json { "application": { ... }, "platforms": [ ... ], "packages": { ... } "modules": { ... }, "templates": { "js/views/hello_world/index.js": [ "templates/hello_world/index.handlebars" ] }, "styles": { ... } } 4
  • 38. A Peek Inside lumbar.json { "application": { ... }, "platforms": [ "android", "iphone", "ipad", "web" ], "packages": { ... } "modules": { ... }, "templates": { ... }, "styles": { "pixelDensity": { "android": [ 1, 1.5 ], "iphone": [ 1, 2 ], "ipad" : [ 1, 2 ], "web": [ 1, 2 ] }, "includes": [ "nib", "styles/include/global.styl" ] } } 4
  • 39. Building with Lumbar . !"" android #   !"" index.html #   !"" native-hello-world.css #   !"" native-hello-world.js #   $"" [email protected] At command-line !"" index.html !"" ipad % lumbar build lumbar.json public #   #   !"" index.html !"" native-hello-world.css #   !"" native-hello-world.js #   $"" [email protected] !"" iphone What you get #   !"" index.html #   !"" native-hello-world.css #   !"" native-hello-world.js #   $"" [email protected] $"" web !"" base.css !"" base.js !"" [email protected] !"" hello_world.css !"" hello_world.js !"" [email protected] $"" index.html 4
  • 41. Conclusion © 2012 SpringOne 2GX. All rights reserved. Do not distribute without permission.
  • 42. Summary The web is consumed by many different kinds of clients Each client platform has unique capabilities and limitations Web applications should target each platform Same application / different experience Lumbar can build platform-specific applications from a general codebase Spring Mobile can detect the platform and direct to a platform-specific site 4
  • 43. Q&A © 2012 SpringOne 2GX. All rights reserved. Do not distribute without permission.