Top Banner
by Jonathan Sharp jQuery on Rails (the real ones)
40

jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

Jul 19, 2018

Download

Documents

nguyendien
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

by Jonathan Sharp

jQuery on Rails (the real ones)

Page 2: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

The Challenge

• Rapid web based application development

• Support multiple server side technologies

• Easy integration of enterprise data

• Additionally Provide• Consistent user experience across all applications•Migrate existing applications• Low cost upgrades

2

Page 3: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

The Scope

•Multiple frameworks: Wicket, Struts, JSF, ColdFusion, Servlets

• Developers• 450+ developers (primarily Java)• Basic HTML, CSS & JS• Geographically dispersed

• Limited Human Factors resources

3

Page 4: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Outline

•Multiple Frameworks

• Rapid Prototyping

• Enterprise Data

4

Page 5: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Audience Survey

• jQuery Experience?• Beginner• Intermediate•Advanced

5

Page 6: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

The Approaches

• Server Side• Consolidate on a single server side framework• XML post processing• Client side library

6

Page 7: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Existing Tools

• Existing Frameworks• ExtJS•Dojo• Prototype/Scriptaculous• jQuery• Tibco GI• GWT

7

Page 8: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Tool Evaluation Criteria

• Developer interface API / education

• Legacy application migration

• Performance

• File size

• Licensing

• Browser support

8

Page 9: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

The Developer Interface

•We put a lot of emphasis on this

• Developer demographics / skill sets

• Application development workflow• Human Factors / Usability Studies• Implementation team

9

Page 10: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Jumping In

•We selected jQuery

• Created a developer centric interface

• Just include & use - short learning curve

• Component driven

10

Page 11: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

The Component

• A component encompasses:• XHTML Markup• Behavior• Enterprise data

• Simple XHTML interface

• Advanced developer interface

11

Page 12: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Semantic Markup

• Developers insert the following XHTML:

• <div class=”groupbox”> <h2>My Groupbox Title</h2> <!-- Groupbox contents --></div>

12

Page 13: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Rendered Markup

• Component renders:

• <div class=”groupbox”> <div><div class=”groupboxTitle”> My Groupbox Title </div></div> <div class=”groupboxContent”> <!-- Groupbox contents --> </div> <div>...</div></div>

13

Page 14: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Alternate Markup Style

• Developers insert the following XHTML:

• <div class=”groupbox” spk:title=”My Groupbox Title”> <!-- Groupbox contents --></div>

14

Page 15: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

The Architecture

• Versioning

• Build Process

• Publishing Releases

• Technical Considerations

• Development Environment

15

Page 16: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Versioning

• <Product Version>.<major>.<minor>• Example: 2.1.4, 2.2.4

•Major & Minor Releases•Major release requires an application change & may break backwards compatibility, url change•Minor releases are transparent to applications, no url change

16

Page 17: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

URL Versioning

•Minor release2.1.5 /product/2.1/product.js2.1.6 /product/2.1/product.js

•Major release2.2.3 /product/2.2/product.js

17

Page 18: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Build Process

• Apache Ant build.xml

• JS Lint

• YUI Compressor (JS & CSS)

• PNG Crush

18

Page 19: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Technical Considerations

• File size / load impact• JS pack vs. min• Caching

• XHTML Transitional doctype

• Require JavaScript to be enabled• Browser support: IE6+, FF2+, Safari

19

Page 20: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Development Environment

• Firefox / Firebug

• IE & script debugging

• SVN for source versioning

• J2EE servlets for Ajax calls (WebLogic)

20

Page 21: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

The Component

• Identified by CSS class • <div class=”component”></div>

• Component initializes on page load• Initialization may also occur by calling Project.init(‘#id’)

21

Page 22: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Custom Attributes & Namespace

• Developed using namespaced attributes• <div spk:attr=”value”>

• HTML5 provides “data” attributes• <div data-attr=”value”>

22

Page 23: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Developer API & Interface

• Basic• XHTML Only, no need to write JavaScript

• Advanced•Add additional behavior with JavaScript

23

Page 24: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Developer API & Interface

• <div id=”gb” class=”groupbox”>• $(‘#gb’) .bind(‘groupboxExpand’, function() { alert(‘Groupbox expanded!’); });

24

Page 25: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Unobtrusive JavaScript

• Behavioral separation• <div onclick=”...”></div>• <div id=”component”></div>• $(‘#component’).bind(‘click’, function() { ...});

• Progressive rendering• <div class=”groupbox”> <h1>Groupbox Title</h1> ...</div>

25

Page 26: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

The Life of a Page

• HTTP Request is made for page• Page requests /spike/2.1/spike.css• Page requests /spike/2.1/spike.js

26

Page 27: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

The Event Cycle

• jQuery $(document).ready(callback)is executed• Trigger user space “before” ready event• Component initialization• Transform the DOM• Add behaviors

• Trigger user space ready event

27

Page 28: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Components In Action

• Application Template

• Groupbox

• Tooltip

28

Page 29: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Outline

•Multiple Frameworks

• Rapid Prototyping

• Enterprise Data

29

Page 30: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Prototyping The UI

• Increasing Productivity•Workflow• Requirements• Prototype interface• Implementation

• Cost of making changes is low

• Developers focus on areas of expertise

30

Page 31: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Prototyping The UI

• Initial Human Factors prototype• Usability study / customer review

• Handoff to application team for implementation

• Reuse XHTML with Wicket, ColdFusion, etc.

31

Page 32: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Outline

•Multiple Frameworks

• Rapid Prototyping

• Enterprise Data

32

Page 33: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Enterprise Data

• UI team develops JSON servlets that talk to XMF/ESB web services (SOA architecture)

• Application teams gain benefits without having to add JAR’s or 3rd party components

• Client side becomes point of aggregation

33

Page 34: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Data Caching / Offline

• Distribute data to the client

• Take advantage of tools such as Google Gears for client side caching

• Increases client side performance, distribution of load

34

Page 35: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Performance Tips

• DOM Manipulation• Consider DOM DocumentFragmenthttp://ejohn.org/blog/dom-documentfragments/• Cache Node References• Take advantage of the jQuery.data() function to solve expando issues

• $(‘#myID’).data(‘rows’, row1,row2,...,n]);

35

Page 36: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Performance Tips

• Tune jQuery Selectors

• Late event binding• Bind click event using mouseover event

• Use event delegation

36

Page 37: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Dynamic Transformations

• On DOM Insert / Update events

• Dynamically initialize components

37

Page 38: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

The UI With Canvas

•Move towards rendering components using Canvas

•MooTools - Mocha UIhttp://mochaui.com/demo/

38

Page 39: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

The Ajax Experience 2008 - jQuery on Rails (the real ones)

Audience Response

• Questions ?

39

Page 40: jQuery On Rails - Revised - Out West Media LLC.outwestmedia.com/presentation/jquery-on-rails/jQueryOnRails.pdf · ColdFusion, Servlets ... •ExtJS •Dojo •Prototype ... jQuery

Thank you! Links & Additional Resourceshttp://outwestmedia.com/TAE/

Jonathan [email protected]